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 committed Oct 24, 2018
1 parent 02f2548 commit 8b1dcda
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 @@ -51,16 +51,13 @@ export default function Keyboard(config, eventBus, editorActions) {
this._eventBus = eventBus;
this._editorActions = editorActions;

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 @@ -134,7 +131,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 @@ -151,7 +148,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 8b1dcda

Please sign in to comment.