developit / developit/unistore
Show how to reuse actions within actions in docs?
- Dominant language
- JavaScript
- Stars
- 2.8k
- Forks
- 134
- PR merge metrics
- No merged PRs in 30d
Description
This works... maybe worth adding to the readme.
```js
// If actions is a function, it gets passed the store:
let actions = store => ({
// Actions can just return a state update:
increment(state) {
return { count: state.count + 1 };
},
// The above example as an Arrow Function:
increment2: ({ count }) => ({ count: count + 1 }),
// Async actions are actions that call store.setState():
incrementAsync(state) {
store.setState(this.increment(state));
setTimeout(() => {
store.setState({ count: store.getState().count + 1 });
}, 1000);
},
});
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.