Last active
February 26, 2018 15:51
-
-
Save ShMcK/194360c2b54c2e55c1008a17e486510c to your computer and use it in GitHub Desktop.
Rematch outline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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