Skip to content

Commit

Permalink
fix: adding jsdoc type defs to Form#on and FormEditor#on methods
Browse files Browse the repository at this point in the history
refs #159
  • Loading branch information
dfulgham authored and fake-join[bot] committed Mar 15, 2022
1 parent 978132e commit 84e3360
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 43 deletions.
45 changes: 24 additions & 21 deletions packages/form-js-editor/src/FormEditor.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import { clone, createFormContainer, createInjector, schemaVersion } from '@bpmn-io/form-js-viewer';
import Ids from 'ids';

import {
isString,
set
} from 'min-dash';

import {
createInjector,
clone,
createFormContainer,
schemaVersion
} from '@bpmn-io/form-js-viewer';
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 @@ -33,19 +22,41 @@ const ids = new Ids([ 32, 36, 1 ]);
* properties: FormEditorProperties,
* schema: Schema
* } } State
*
* @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 = {}) {

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

/**
* @public
* @type {String}
Expand Down Expand Up @@ -221,14 +232,6 @@ export default class FormEditor {
this._setState({ properties });
}

/**
* @param {string} type
* @param {number} priority
* @param {Function} handler
*/
on(type, priority, handler) {
this.get('eventBus').on(type, priority, handler);
}

/**
* @param {string} type
Expand Down
47 changes: 25 additions & 22 deletions packages/form-js-viewer/src/Form.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import Ids from 'ids';

import {
get,
isString,
set
} from 'min-dash';

import {
clone,
createInjector,
createFormContainer,
pathStringify
} from './util';
import { get, isString, set } from 'min-dash';

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

/**
* @typedef { import('./types').Injector } Injector
Expand All @@ -32,21 +21,44 @@ import core from './core';
* properties: FormProperties,
* schema: Schema
* } } State
*
* @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 = {}) {

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

/**
* @public
* @type {String}
Expand Down Expand Up @@ -296,15 +308,6 @@ export default class Form {
this._setState({ properties });
}

/**
* @param {FormEvent} type
* @param {number} priority
* @param {Function} handler
*/
on(type, priority, handler) {
this.get('eventBus').on(type, priority, handler);
}

/**
* @param {FormEvent} type
* @param {Function} handler
Expand Down

0 comments on commit 84e3360

Please sign in to comment.