blob: 16308fae44d41b0c7ee187f56e58adbd05a4a47a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
export default class ActionBinding {
action;
isActive = false;
constructor(action) {
this.action = action;
}
start() {
if (!this.isActive) {
const { action } = this;
action[0].listen(action[1]);
this.isActive = true;
}
}
stop() {
if (this.isActive) {
const { action } = this;
action[0].off(action[1]);
this.isActive = false;
}
}
}
export const createActionBindings = actions =>
actions.map(a => new ActionBinding(a));
|