Skip to content

Commit

Permalink
Make keyResponder ember-modifier@4 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli authored Jul 6, 2022
1 parent ffbade8 commit f808d1a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions addon/src/decorators/key-responder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { inject as service } from '@ember/service';
import { registerDestructor } from '@ember/destroyable';

function populateKeyboardHandlers(responder) {
responder.keyboardHandlers = responder.keyboardHandlers || {};
Expand Down Expand Up @@ -36,7 +37,7 @@ export default function keyResponder(opts = {}) {

return class ClassAsKeyResponder extends DecoratedClass {
static name = `${DecoratedClass.name}WithKeyResponder`;

@service keyboard;

get keyboardPriority() {
Expand Down Expand Up @@ -65,11 +66,10 @@ export default function keyResponder(opts = {}) {
super(...arguments);
populateKeyboardHandlers(this);
this.keyboard.register(this);
}

willDestroy() {
this.keyboard.unregister(this);
super.willDestroy(...arguments);

registerDestructor(this, () => {
this.keyboard.unregister(this);
});
}
};
};
Expand Down

0 comments on commit f808d1a

Please sign in to comment.