aboutsummaryrefslogtreecommitdiffstats
path: root/docs/example-feature/store.js
diff options
context:
space:
mode:
authorLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-03-19 11:46:30 +0100
committerLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-03-19 11:46:30 +0100
commitab9ae1829e51e463d644ff369ebc3434f2f42c81 (patch)
tree639b4dc0c0d519fbd2bf99c869b00bce1ccfb5cf /docs/example-feature/store.js
parentmerge-in webview unmounting fix (diff)
parentMerge pull request #1338 from meetfranz/chore/app-feature-helpers (diff)
downloadferdium-app-ab9ae1829e51e463d644ff369ebc3434f2f42c81.tar.gz
ferdium-app-ab9ae1829e51e463d644ff369ebc3434f2f42c81.tar.zst
ferdium-app-ab9ae1829e51e463d644ff369ebc3434f2f42c81.zip
fix conflicts with latest develop
Diffstat (limited to 'docs/example-feature/store.js')
-rw-r--r--docs/example-feature/store.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/docs/example-feature/store.js b/docs/example-feature/store.js
new file mode 100644
index 000000000..d8acfdca3
--- /dev/null
+++ b/docs/example-feature/store.js
@@ -0,0 +1,32 @@
1import { action, observable, reaction } from 'mobx';
2import Store from '../../src/stores/lib/Store';
3import Request from '../../src/stores/lib/Request';
4
5const debug = require('debug')('Franz:feature:EXAMPLE_FEATURE:store');
6
7export class ExampleFeatureStore extends Store {
8 @observable getNameRequest = new Request(this.api, 'getName');
9
10 constructor(stores, api, actions, state) {
11 super(stores, api, actions);
12 this.state = state;
13 }
14
15 setup() {
16 debug('fetching name from api');
17 this.getNameRequest.execute();
18
19 // Update the name on the state when the request resolved
20 reaction(
21 () => this.getNameRequest.result,
22 name => this._setName(name),
23 );
24 }
25
26 @action _setName = (name) => {
27 debug('setting name', name);
28 this.state.name = name;
29 };
30}
31
32export default ExampleFeatureStore;