From 84146570bb306cc08f7b7506c0bd71035d0f3b0b Mon Sep 17 00:00:00 2001 From: Max Tru Date: Tue, 15 Mar 2022 09:36:22 +0100 Subject: [PATCH] chore: clean-up jsdoc for Form#on FormEditor#on closes #159 --- packages/form-js-editor/src/FormEditor.js | 27 +++++++++------------- packages/form-js-viewer/src/Form.js | 28 +++++++++-------------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/packages/form-js-editor/src/FormEditor.js b/packages/form-js-editor/src/FormEditor.js index db86fec6f..88b321a45 100644 --- a/packages/form-js-editor/src/FormEditor.js +++ b/packages/form-js-editor/src/FormEditor.js @@ -23,8 +23,8 @@ const ids = new Ids([ 32, 36, 1 ]); * schema: Schema * } } State * - * @typedef { (type:string,priority:number,handler:Function) => void } OnEventWithPriority; - * @typedef { (type:string,handler:Function) => void } OnEventWithOutPriority; + * @typedef { (type:string, priority:number, handler:Function) => void } OnEventWithPriority; + * @typedef { (type:string, handler:Function) => void } OnEventWithOutPriority; * @typedef { OnEventWithPriority & OnEventWithOutPriority} OnEventType */ @@ -33,19 +33,6 @@ const ids = new Ids([ 32, 36, 1 ]); */ export default class FormEditor { - - /** - * private OnEvent function definition - * - */ - _onEvent = (type,priority,handler) => { - if (typeof priority === 'function' && typeof handler === 'undefined') { - handler = priority; - priority = 0; - } - this.get('eventBus').on(type, priority, handler); - } - /** * @constructor * @param {FormEditorOptions} options @@ -53,8 +40,9 @@ export default class FormEditor { constructor(options = {}) { /** + * @public * @type {OnEventType} - */ + */ this.on = this._onEvent; /** @@ -311,6 +299,13 @@ export default class FormEditor { ]; } + /** + * @internal + */ + _onEvent = (type, priority, handler) => { + this.get('eventBus').on(type, priority, handler); + } + } // helpers ////////// diff --git a/packages/form-js-viewer/src/Form.js b/packages/form-js-viewer/src/Form.js index c48033d89..bb9897403 100644 --- a/packages/form-js-viewer/src/Form.js +++ b/packages/form-js-viewer/src/Form.js @@ -22,13 +22,11 @@ import { clone, createFormContainer, createInjector, pathStringify } from './uti * schema: Schema * } } State * - * @typedef { (type:FormEvent,priority:number,handler:Function) => void } OnEventWithPriority; - * @typedef { (type:FormEvent,handler:Function) => void } OnEventWithOutPriority; + * @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority; + * @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority; * @typedef { OnEventWithPriority & OnEventWithOutPriority} OnEventType */ - - const ids = new Ids([ 32, 36, 1 ]); /** @@ -36,18 +34,6 @@ const ids = new Ids([ 32, 36, 1 ]); */ export default class Form { - /** - * private OnEvent function definition - * - */ - _onEvent = (type,priority,handler) => { - if (typeof priority === 'function' && typeof handler === 'undefined') { - handler = priority; - priority = 0; - } - this.get('eventBus').on(type, priority, handler); - } - /** * @constructor * @param {FormOptions} options @@ -55,8 +41,9 @@ export default class Form { constructor(options = {}) { /** + * @public * @type {OnEventType} - */ + */ this.on = this._onEvent; /** @@ -403,4 +390,11 @@ export default class Form { this._emit('changed', this._getState()); } + /** + * @internal + */ + _onEvent = (type, priority, handler) => { + this.get('eventBus').on(type, priority, handler); + } + } \ No newline at end of file