Skip to content

Commit

Permalink
feat(keyboard): remove listeners from lifecycle events
Browse files Browse the repository at this point in the history
BREAKING CHANGE: lifecycle listeners will no longer receive field listeners

* Listeners are no longer stored inside Keyboard.
* Field `listeners` was removed from lifecycle events.

Closes #226
  • Loading branch information
barmac authored and merge-me[bot] committed Oct 25, 2018
1 parent d59474c commit 4d72e38
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/features/keyboard/Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var DEFAULT_PRIORITY = 1000;
* - keyboard.init
* - keyboard.destroy
*
* All events contain the fields (node, listeners).
* All events contain one field which is node.
*
* A default binding for the keyboard may be specified via the
* `keyboard.bindTo` configuration option.
Expand All @@ -49,16 +49,13 @@ export default function Keyboard(config, eventBus) {
this._config = config || {};
this._eventBus = eventBus;

this._listeners = [];
this._keyHandler = this._keyHandler.bind(this);

// properly clean dom registrations
eventBus.on('diagram.destroy', function() {
self._fire('destroy');

self.unbind();

self._listeners = [];
});

eventBus.on('diagram.init', function() {
Expand Down Expand Up @@ -131,7 +128,7 @@ Keyboard.prototype.unbind = function() {
};

Keyboard.prototype._fire = function(event) {
this._eventBus.fire('keyboard.' + event, { node: this._node, listeners: this._listeners });
this._eventBus.fire('keyboard.' + event, { node: this._node });
};

/**
Expand All @@ -148,7 +145,6 @@ Keyboard.prototype.addListener = function(priority, listener) {
priority = DEFAULT_PRIORITY;
}

this._listeners.push(listener);
this._eventBus.on(KEYDOWN_EVENT, priority, listener);
};

Expand Down

0 comments on commit 4d72e38

Please sign in to comment.