Skip to content

Instantly share code, notes, and snippets.

@aGuyNamedJonas
Last active April 11, 2017 19:48
Show Gist options
  • Save aGuyNamedJonas/f8a912e59f6458ba7c952ca4f57f4c39 to your computer and use it in GitHub Desktop.
Save aGuyNamedJonas/f8a912e59f6458ba7c952ca4f57f4c39 to your computer and use it in GitHub Desktop.
// 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