aboutsummaryrefslogtreecommitdiffstats
path: root/docs/example-feature/index.js
diff options
context:
space:
mode:
authorLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-03-12 18:20:56 +0100
committerLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-03-12 18:20:56 +0100
commitd51283b5f89d42814a340b7cd77e6544d23aa243 (patch)
treef0e56e577d53987d22db44a8a87e5f37b8ea6ea8 /docs/example-feature/index.js
parentadd useful helpers for building standalone app features (diff)
downloadferdium-app-d51283b5f89d42814a340b7cd77e6544d23aa243.tar.gz
ferdium-app-d51283b5f89d42814a340b7cd77e6544d23aa243.tar.zst
ferdium-app-d51283b5f89d42814a340b7cd77e6544d23aa243.zip
add example feature template to docs folder
Diffstat (limited to 'docs/example-feature/index.js')
-rw-r--r--docs/example-feature/index.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/docs/example-feature/index.js b/docs/example-feature/index.js
new file mode 100644
index 000000000..af859af26
--- /dev/null
+++ b/docs/example-feature/index.js
@@ -0,0 +1,36 @@
1import { reaction, runInAction } from 'mobx';
2import { ExampleFeatureStore } from './store';
3import state, { resetState } from './state';
4import api from './api';
5
6const debug = require('debug')('Franz:feature:EXAMPLE_FEATURE');
7
8let store = null;
9
10export default function initAnnouncements(stores, actions) {
11 const { features } = stores;
12
13 // Toggle workspace feature
14 reaction(
15 () => (
16 features.features.isExampleFeatureEnabled
17 ),
18 (isEnabled) => {
19 if (isEnabled) {
20 debug('Initializing `EXAMPLE_FEATURE` feature');
21 store = new ExampleFeatureStore(stores, api, actions, state);
22 store.initialize();
23 runInAction(() => { state.isFeatureActive = true; });
24 } else if (store) {
25 debug('Disabling `EXAMPLE_FEATURE` feature');
26 runInAction(() => { state.isFeatureActive = false; });
27 store.teardown();
28 store = null;
29 resetState(); // Reset state to default
30 }
31 },
32 {
33 fireImmediately: true,
34 },
35 );
36}