0.2.1 • Published 7 years ago

redux-middlewares v0.2.1

Weekly downloads
8
License
MIT
Repository
github
Last release
7 years ago

redux-middlewares

A library to create middlewares.

It fits to prototyping or small projects.

Install

$ npm install -S redux-middlewares

Links and recipes

API

composeMiddleware(...middlewares)

It works like Redux's applyMiddleware but returns a middleware instead of a store enhancer.

createMiddleware(...matchers, callback)

Calls the given callback only an action is matched to all matchers.

By caching, it does not call store.getState more than once at matching.
All other create* functions use this function internally.

  • matcher string | array | ({action, getState}) => boolean
    • string An action type to match
    • array An array of action types to match
    • ({action, getState}) => boolean A function returns true if matched
  • callback ({getState, dispatch, nextDispatch, action}) => any

createAsyncHook(...matchers, callback)

Calls the given callback asynchronously.

Asynchronous version of createMiddleware.
It calls nextDispatch immediately.

  • matcher string | array | ({action, getState}) => boolean
    • string An action type to match
    • array An array of action types to match
    • ({action, getState}) => boolean A function returns true if matched
  • callback ({getState, dispatch, action}) => any

createFilter(...matchers, filter)

Filters actions.

It calls nextDispatch if the filter returns true.

  • filter ({action, getState}) => boolean

createTransformer(...matchers, transformer)

Transforms an action in the middleware layer.

  • transformer ({action, getState}) => action

createReplacer(...matchers, replacer)

Discards an action and dispatch a new one.

  • replacer ({action, getState}) => action
0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.0

7 years ago