mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
5187d142ea
* Usage with rematch * Run lint fix * Add counter-display example and readme
20 lines
463 B
JavaScript
20 lines
463 B
JavaScript
const counter = {
|
|
state: 0, // initial state
|
|
reducers: {
|
|
// handle state changes with pure functions
|
|
increment (state, payload) {
|
|
return state + payload
|
|
}
|
|
},
|
|
effects: {
|
|
// handle state changes with impure functions.
|
|
// use async/await for async actions
|
|
async incrementAsync (payload, rootState) {
|
|
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
this.increment(payload)
|
|
}
|
|
}
|
|
}
|
|
|
|
export default counter
|