Created
August 12, 2015 10:54
-
-
Save Delapouite/17e2dd4dd9e169899b4c to your computer and use it in GitHub Desktop.
Currying with ES6 fat arrows
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
// 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