Skip to content

Commit

Permalink
chore: clean-up jsdoc for Form#on FormEditor#on
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxTru committed Mar 15, 2022
1 parent 9164977 commit 8414657
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 33 deletions.
27 changes: 11 additions & 16 deletions packages/form-js-editor/src/FormEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand All @@ -33,28 +33,16 @@ 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
*/
constructor(options = {}) {

/**
* @public
* @type {OnEventType}
*/
*/
this.on = this._onEvent;

/**
Expand Down Expand Up @@ -311,6 +299,13 @@ export default class FormEditor {
];
}

/**
* @internal
*/
_onEvent = (type, priority, handler) => {
this.get('eventBus').on(type, priority, handler);
}

}

// helpers //////////
Expand Down
28 changes: 11 additions & 17 deletions packages/form-js-viewer/src/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,28 @@ 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 ]);

/**
* The form.
*/
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
*/
constructor(options = {}) {

/**
* @public
* @type {OnEventType}
*/
*/
this.on = this._onEvent;

/**
Expand Down Expand Up @@ -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);
}

}

0 comments on commit 8414657

Please sign in to comment.