UNPKG

rako

Version:

[![LICENSE](https://img.shields.io/badge/license-MIT%20(The%20996%20Prohibited%20License)-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE)

20 lines (16 loc) 506 B
function applyMiddleware(middlewares) { return function enhancer(getState, updateStore, actions) { let next = updateStore function runMiddlewares(substate, extra, type, isSync) { return next(substate, extra, type, isSync) } const nexts = middlewares.map(middleware => middleware(getState, runMiddlewares, actions)) for (let i = nexts.length - 1; i >= 0; i--) { next = nexts[i](next) } return runMiddlewares } } export { applyMiddleware }