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
closes #159
  • Loading branch information
MaxTru authored and fake-join[bot] committed Mar 15, 2022
1 parent 84e3360 commit 6a86624
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 35 deletions.
30 changes: 13 additions & 17 deletions packages/form-js-editor/src/FormEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Ids from 'ids';
import { isString, set } from 'min-dash';

import core from './core';

import EditorActionsModule from './features/editor-actions';
import KeyboardModule from './features/keyboard';
import ModelingModule from './features/modeling';
Expand All @@ -23,38 +24,26 @@ 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 { OnEventWithPriority & OnEventWithOutPriority} OnEventType
* @typedef { (type:string, priority:number, handler:Function) => void } OnEventWithPriority
* @typedef { (type:string, handler:Function) => void } OnEventWithOutPriority
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
*/

/**
* The form editor.
*/
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 +300,13 @@ export default class FormEditor {
];
}

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

}

// helpers //////////
Expand Down
31 changes: 13 additions & 18 deletions packages/form-js-viewer/src/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Ids from 'ids';
import { get, isString, set } from 'min-dash';

import core from './core';

import { clone, createFormContainer, createInjector, pathStringify } from './util';

/**
Expand All @@ -22,41 +23,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 { OnEventWithPriority & OnEventWithOutPriority} OnEventType
* @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 +391,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 6a86624

Please sign in to comment.