5.0.1 • Published 3 years ago

dispatch-next-action v5.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

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 ]
5.0.1

3 years ago

5.0.0

4 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

6 years ago