Skip to content

hbina/fraud-redux-mapper

Repository files navigation

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.

About

Maps some action to some lambda.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published