diff options
Diffstat (limited to 'src/features/planSelection/index.js')
-rw-r--r-- | src/features/planSelection/index.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/features/planSelection/index.js b/src/features/planSelection/index.js new file mode 100644 index 000000000..81189207a --- /dev/null +++ b/src/features/planSelection/index.js | |||
@@ -0,0 +1,30 @@ | |||
1 | import { reaction } from 'mobx'; | ||
2 | import PlanSelectionStore from './store'; | ||
3 | |||
4 | const debug = require('debug')('Franz:feature:planSelection'); | ||
5 | |||
6 | export const GA_CATEGORY_PLAN_SELECTION = 'planSelection'; | ||
7 | |||
8 | export const planSelectionStore = new PlanSelectionStore(); | ||
9 | |||
10 | export default function initPlanSelection(stores, actions) { | ||
11 | stores.planSelection = planSelectionStore; | ||
12 | const { features } = stores; | ||
13 | |||
14 | // Toggle planSelection feature | ||
15 | reaction( | ||
16 | () => features.features.isPlanSelectionEnabled, | ||
17 | (isEnabled) => { | ||
18 | if (isEnabled) { | ||
19 | debug('Initializing `planSelection` feature'); | ||
20 | planSelectionStore.start(stores, actions); | ||
21 | } else if (planSelectionStore.isFeatureActive) { | ||
22 | debug('Disabling `planSelection` feature'); | ||
23 | planSelectionStore.stop(); | ||
24 | } | ||
25 | }, | ||
26 | { | ||
27 | fireImmediately: true, | ||
28 | }, | ||
29 | ); | ||
30 | } | ||