blob: d8acfdca33d822858ebef06190ccd286d1fb3161 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import { action, observable, reaction } from 'mobx';
import Store from '../../src/stores/lib/Store';
import Request from '../../src/stores/lib/Request';
const debug = require('debug')('Franz:feature:EXAMPLE_FEATURE:store');
export class ExampleFeatureStore extends Store {
@observable getNameRequest = new Request(this.api, 'getName');
constructor(stores, api, actions, state) {
super(stores, api, actions);
this.state = state;
}
setup() {
debug('fetching name from api');
this.getNameRequest.execute();
// Update the name on the state when the request resolved
reaction(
() => this.getNameRequest.result,
name => this._setName(name),
);
}
@action _setName = (name) => {
debug('setting name', name);
this.state.name = name;
};
}
export default ExampleFeatureStore;
|