import { staticMiddleware } from 'dispatch-next-action'
const middleware = (dispatch, context) => next => (action, ...args) =>
next(action)
const dispatch = staticMiddleware(middleware)
import { dynamicMiddleware } from 'dispatch-next-action'
const logger = (dispatch, context, onDelete) => next => (...args) => {
console.log(args)
return next(...args)
}
const dispatch = dynamicMiddleware()
dispatch.push(logger)
dispatch(1, 2, 3)
(dispatch, context, onDelete) => next => (...args) => {}
Any function registered with onDelete will be called when middleware is removed.
import {
bridge,
dynamicMiddleware,
staticMiddleware,
} from 'dispatch-next-action'
const dynamic = dynamicMiddleware()
const dispatch = staticMiddleware(bridge(dynamic))
dispatch(1, 2, 3) // [ 1, 2, 3 ]