-
-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathcreate-store.ts
More file actions
29 lines (23 loc) · 728 Bytes
/
create-store.ts
File metadata and controls
29 lines (23 loc) · 728 Bytes
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
import { action, createStore, EasyPeasyConfig, Action } from 'easy-peasy';
interface StoreModel {
foo: string;
update: Action<StoreModel, string>;
}
const model: StoreModel = {
foo: 'bar',
update: action((state, payload) => {
state.foo = payload;
}),
};
const storeWithoutConfig = createStore(model);
storeWithoutConfig.getMockedActions().length;
storeWithoutConfig.clearMockedActions();
storeWithoutConfig.getState().foo;
storeWithoutConfig.getActions().update('bar');
const config: EasyPeasyConfig = {
mockActions: true,
};
const storeWithConfig = createStore(model, config);
storeWithConfig.getMockedActions().length;
storeWithoutConfig.clearMockedActions();
storeWithConfig.getActions().update('bar');