Skip to content

Instantly share code, notes, and snippets.

@squeedee
Last active November 23, 2015 14:41
Show Gist options
  • Save squeedee/1a3f46ebc690c396dc7f to your computer and use it in GitHub Desktop.
Save squeedee/1a3f46ebc690c396dc7f to your computer and use it in GitHub Desktop.
refactoring functions that compose anonymous higher order functions
App.changeReleaseAttribute = function(attributeName, newValue){
AppStore.transact(function(app){
return app.mergeIn(['release', attributeName], newValue);
});
};
App.changeReleaseAttribute = function(attributeName, newValue) {
AppStore.transact([attributeName, newValue], ReleaseMutators.changeAttribute);
};
ReleaseMutators.changeAttribute = function(app, attributeName, newValue) {
return app.mergeIn(['release', attributeName], newValue);
}
App.changeReleaseAttribute = function(payload) {
AppStore.transact(payload, ReleaseMutators.changeAttribute);
};
ReleaseMutators.changeAttribute = function(app, payload) {
return app.mergeIn(['release', payload.attributeName], payload.newValue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment