fraud-redux-mapper
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Fraud Redux-Mapper

A Redux middleware that maps an action to some lambda.

Usage

To use this middleware, simply provide a table of ActionMap<S, A>[].

const store = createStore(
  reducer,
  applyMiddleware(
    createMapper([
      createActionMap('SOME_ACTION', (store) => {
        store.dispatch({ type: 'THIS_ACTION' })
      }),
      createActionMap('SOME_OTHER_ACTION', (store) => {
        store.dispatch({ type: 'THAT_ACTION' })
      }),
    ])
  )
)

Where the type signature for ActionMap<S, A>[] is,

export type ActionMap<S, A> = {
  from: A
  to: (a: MiddlewareAPI<Dispatch<AnyAction>, S>) => void
}

Or simply, it maps a certain action from to some function to that accepts the reducer.

Package Sidebar

Install

npm i fraud-redux-mapper

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

35.9 kB

Total Files

35

Last publish

Collaborators

  • fraud