blob: 3665812e6b599d04defbc8872dce59f102746abe (
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
29
|
import { reaction } from 'mobx';
import TodoStore from './store';
const debug = require('debug')('Ferdi:feature:todos');
export const todosStore = new TodoStore();
export default function initTodos(
stores: { todos?: any; features?: any },
actions: any,
) {
stores.todos = todosStore;
const { features } = stores;
// Toggle todos feature
reaction(
() => features.features.isTodosEnabled,
isEnabled => {
if (isEnabled) {
debug('Initializing `todos` feature');
todosStore.start(stores, actions);
} else if (todosStore.isFeatureActive) {
debug('Disabling `todos` feature');
todosStore.stop();
}
},
{ fireImmediately: true },
);
}
|