Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

dispatch-next-action

rogerbf4MIT5.0.1

compose static/dynamic middleware

middleware, dynamic, dispatcher, dispatch, immutable, mutable

readme

dispatch-next-action

usage

staticMiddleware([context][...middleware])

import { staticMiddleware } from 'dispatch-next-action'

const middleware = (dispatch, context) => next => (action, ...args) =>
  next(action)

const dispatch = staticMiddleware(middleware)

dynamicMiddleware([context][...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)

middleware signature

(dispatch, context, onDelete) => next => (...args) => {}

Any function registered with onDelete will be called when middleware is removed.

Instance methods

dispatch([...args])
dispatch.includes(middleware)
dispatch.push(middleware[, ...middleware])
dispatch.unshift(middleware[, ...middleware])
dispatch.splice(start, deleteCount[, ...middleware])
dispatch.splice(start[, ...middleware])
dispatch.clear()
dispatch.delete(middleware[, ...middleware])

bridge

import {
  bridge,
  dynamicMiddleware,
  staticMiddleware,
} from 'dispatch-next-action'

const dynamic = dynamicMiddleware()
const dispatch = staticMiddleware(bridge(dynamic))

dispatch(1, 2, 3) // [ 1, 2, 3 ]