diff options
Diffstat (limited to 'src/features/todos/index.js')
-rw-r--r-- | src/features/todos/index.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/features/todos/index.js b/src/features/todos/index.js new file mode 100644 index 000000000..7388aebaf --- /dev/null +++ b/src/features/todos/index.js | |||
@@ -0,0 +1,39 @@ | |||
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 | export const DEFAULT_IS_FEATURE_ENABLED_BY_USER = true; | ||
12 | |||
13 | export const TODOS_ROUTES = { | ||
14 | TARGET: '/todos', | ||
15 | }; | ||
16 | |||
17 | export const todosStore = new TodoStore(); | ||
18 | |||
19 | export default function initTodos(stores, actions) { | ||
20 | stores.todos = todosStore; | ||
21 | const { features } = stores; | ||
22 | |||
23 | // Toggle todos feature | ||
24 | reaction( | ||
25 | () => features.features.isTodosEnabled, | ||
26 | (isEnabled) => { | ||
27 | if (isEnabled) { | ||
28 | debug('Initializing `todos` feature'); | ||
29 | todosStore.start(stores, actions); | ||
30 | } else if (todosStore.isFeatureActive) { | ||
31 | debug('Disabling `todos` feature'); | ||
32 | todosStore.stop(); | ||
33 | } | ||
34 | }, | ||
35 | { | ||
36 | fireImmediately: true, | ||
37 | }, | ||
38 | ); | ||
39 | } | ||