From 76bf7b840ea7d607a21b0294d10be01b26ad0607 Mon Sep 17 00:00:00 2001 From: Dominik Guzei Date: Fri, 12 Apr 2019 15:51:57 +0200 Subject: merge-in latest develop --- src/features/utils/ActionBinding.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/features/utils/ActionBinding.js (limited to 'src/features/utils/ActionBinding.js') diff --git a/src/features/utils/ActionBinding.js b/src/features/utils/ActionBinding.js new file mode 100644 index 000000000..497aa071b --- /dev/null +++ b/src/features/utils/ActionBinding.js @@ -0,0 +1,29 @@ +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)) +); -- cgit v1.2.3-70-g09d2