Skip to content

Instantly share code, notes, and snippets.

@ShMcK
Last active February 26, 2018 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShMcK/194360c2b54c2e55c1008a17e486510c to your computer and use it in GitHub Desktop.
Save ShMcK/194360c2b54c2e55c1008a17e486510c to your computer and use it in GitHub Desktop.
Rematch outline
import { init, dispatch } from '@rematch/core'
import delay from './makeMeWait.js'
const count = {
state: 0,
reducers: {
increment: (state, payload) => state + payload,
decrement: (state, payload) => state - payload,
},
effects: {
async incrementAsync(payload) {
await delay(1000)
this.increment(payload)
}
}
}
const store = init({
models: { count },
redux: { /* configure redux here */ }
})
dispatch.count.incrementAsync(1) // wait, then state = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment