From bfe8847d72cd0893230f2e654242658214943e61 Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Sat, 2 Oct 2021 09:24:32 +0200 Subject: chore: convert various files from JS to TS (#2010) --- src/features/todos/index.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/features/todos/index.ts (limited to 'src/features/todos/index.ts') diff --git a/src/features/todos/index.ts b/src/features/todos/index.ts new file mode 100644 index 000000000..3665812e6 --- /dev/null +++ b/src/features/todos/index.ts @@ -0,0 +1,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 }, + ); +} -- cgit v1.2.3-70-g09d2