Created
November 8, 2016 18:33
-
-
Save raypulver/41336e2118e035e6b6bf24c8f70349fb to your computer and use it in GitHub Desktop.
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
| const { create, assign } = Object, | |
| { dispatch, getState } = (function () { | |
| let state = { | |
| a: 5 | |
| }; | |
| const reduce = (last, action) => { | |
| const { type, payload } = action; | |
| switch (type) { | |
| case 'INCREMENT_A': | |
| return assign({ a: last.a + payload }, last); | |
| } | |
| return last; | |
| }; | |
| } | |
| return { | |
| dispatch: (action) => { | |
| state = reduce(state, action); | |
| }, | |
| getState: () => state | |
| }; | |
| })(); | |
| dispatch({ | |
| type: 'INCREMENT_A', | |
| payload: 5 | |
| }); | |
| log(getState().a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment