Last active
April 11, 2017 19:48
-
-
Save aGuyNamedJonas/f8a912e59f6458ba7c952ca4f57f4c39 to your computer and use it in GitHub Desktop.
This file contains 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
// Register a change with the actionType 'INCREMENT' and the appropriate reducer. | |
// This returns a change-trigger function (see below) | |
const increment = store.createChangeTrigger({ | |
actionType: 'INCREMENT', | |
reducer: (state, payload, action) => { | |
return state + payload.value; | |
} | |
}); | |
// Calling increment() will dispatch the following action: | |
// {type: 'INCREMENT', payload: {value: 10}} | |
increment({value: 10}); | |
/* | |
This will be picked up by the internal slim-redux reducer | |
which in turn will execute your previously provided reducer code: | |
reducer: (state, payload, action) => { | |
return state + payload.value; | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment