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
Bhargav Ponnapalli 5187d142ea Added example for usage with rematch (#4095)
* Usage with rematch

* Run lint fix

* Add counter-display example and readme
2018-04-18 14:03:24 +02:00

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