diff options
Diffstat (limited to 'src/features/workspaces/index.ts')
-rw-r--r-- | src/features/workspaces/index.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/features/workspaces/index.ts b/src/features/workspaces/index.ts new file mode 100644 index 000000000..ecca64b41 --- /dev/null +++ b/src/features/workspaces/index.ts | |||
@@ -0,0 +1,28 @@ | |||
1 | import { reaction } from 'mobx'; | ||
2 | import WorkspacesStore from './store'; | ||
3 | import { resetApiRequests } from './api'; | ||
4 | |||
5 | const debug = require('debug')('Ferdi:feature:workspaces'); | ||
6 | |||
7 | export const workspaceStore = new WorkspacesStore(); | ||
8 | |||
9 | export default function initWorkspaces(stores, actions) { | ||
10 | stores.workspaces = workspaceStore; | ||
11 | const { features } = stores; | ||
12 | |||
13 | // Toggle workspace feature | ||
14 | reaction( | ||
15 | () => features.features.isWorkspaceEnabled, | ||
16 | isEnabled => { | ||
17 | if (isEnabled && !workspaceStore.isFeatureActive) { | ||
18 | debug('Initializing `workspaces` feature'); | ||
19 | workspaceStore.start(stores, actions); | ||
20 | } else if (workspaceStore.isFeatureActive) { | ||
21 | debug('Disabling `workspaces` feature'); | ||
22 | workspaceStore.stop(); | ||
23 | resetApiRequests(); | ||
24 | } | ||
25 | }, | ||
26 | { fireImmediately: true }, | ||
27 | ); | ||
28 | } | ||