Skip to content

Instantly share code, notes, and snippets.

@aGuyNamedJonas
Created April 11, 2017 16:03
Show Gist options
  • Save aGuyNamedJonas/4cfe63e3c812006cb3aad77ac3bd1cfc to your computer and use it in GitHub Desktop.
Save aGuyNamedJonas/4cfe63e3c812006cb3aad77ac3bd1cfc to your computer and use it in GitHub Desktop.
var decrement = store.createChangeTrigger({
actionType: 'DECREMENT',
reducer: (state, payload, action) => {
const value = payload.value || 1;
return state - value;
},
// Payload validation - notice how it returns either reject() with a message or
// accept() to let slim-redux know whether the validation passed or not.
payloadValidation: (payload, accept, reject) => {
if(!payload || !payload.value)
return reject({
msg: 'No parameters given or no "value" attribute in parameters provided!',
params: payload
});
else
return accept();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment