Skip to content

Instantly share code, notes, and snippets.

@nuintun
Last active September 16, 2021 02:34
Show Gist options
  • Save nuintun/87d03b6ed04325ad28fe9a9c5538a879 to your computer and use it in GitHub Desktop.
Save nuintun/87d03b6ed04325ad28fe9a9c5538a879 to your computer and use it in GitHub Desktop.
redux-compose 实现
/**
* @function compose
* @description compose redux middlewares
* @param {function[]} funcs
* @returns {function}
*/
function compose(middlewares) {
return middlewares.reduce((compose, middleware) => {
return (...args) => compose(middleware(...args));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment