diff options
Diffstat (limited to 'src/features/todos/index.js')
-rw-r--r-- | src/features/todos/index.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/features/todos/index.js b/src/features/todos/index.js new file mode 100644 index 000000000..00b165cc5 --- /dev/null +++ b/src/features/todos/index.js | |||
@@ -0,0 +1,34 @@ | |||
1 | import { reaction } from 'mobx'; | ||
2 | import TodoStore from './store'; | ||
3 | |||
4 | const debug = require('debug')('Franz:feature:todos'); | ||
5 | |||
6 | export const GA_CATEGORY_TODOS = 'Todos'; | ||
7 | |||
8 | export const DEFAULT_TODOS_WIDTH = 300; | ||
9 | export const TODOS_MIN_WIDTH = 200; | ||
10 | export const DEFAULT_TODOS_VISIBLE = true; | ||
11 | |||
12 | export const todosStore = new TodoStore(); | ||
13 | |||
14 | export default function initTodos(stores, actions) { | ||
15 | stores.todos = todosStore; | ||
16 | const { features } = stores; | ||
17 | |||
18 | // Toggle todos feature | ||
19 | reaction( | ||
20 | () => features.features.isTodosEnabled, | ||
21 | (isEnabled) => { | ||
22 | if (isEnabled) { | ||
23 | debug('Initializing `todos` feature'); | ||
24 | todosStore.start(stores, actions); | ||
25 | } else if (todosStore.isFeatureActive) { | ||
26 | debug('Disabling `todos` feature'); | ||
27 | todosStore.stop(); | ||
28 | } | ||
29 | }, | ||
30 | { | ||
31 | fireImmediately: true, | ||
32 | }, | ||
33 | ); | ||
34 | } | ||