1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-rematch/shared/models/counter.js

20 lines
463 B
JavaScript
Raw Normal View History

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