Skip to content

Instantly share code, notes, and snippets.

@Delapouite
Created August 12, 2015 10:54
Show Gist options
  • Save Delapouite/17e2dd4dd9e169899b4c to your computer and use it in GitHub Desktop.
Save Delapouite/17e2dd4dd9e169899b4c to your computer and use it in GitHub Desktop.
Currying with ES6 fat arrows
// example taken from redux middleware docs : http://gaearon.github.io/redux/docs/advanced/Middleware.html
// ES5
function logger (store) {
return function (next) {
return function (action) {
console.log('dispatching', action);
var result = next(action);
console.log('next state', store.getState());
return result;
};
}
}
// ES6
const logger = store => next => action => {
console.log('dispatching', action);
let result = next(action);
console.log('next state', store.getState());
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment