Created
April 11, 2017 16:03
-
-
Save aGuyNamedJonas/4cfe63e3c812006cb3aad77ac3bd1cfc 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
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