JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 142
  • Score
    100M100P100Q61995F
  • License MIT

Redux functional programming utilities

Package Exports

  • redux-fun

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redux-fun) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

redux-fun

Redux functional programming utilities

Install

$ npm install --save redux-fun

Documentation

Reducers


Compose reducers
  const { composeReducers, pipeReducers } = require('redux-fun');

  const reducer_1 = composeReducers(r3, r2, r1);
  const reducer_2 = pipeReducers(r1, r2, r3);
Convert updaters
const { toReducer } = require('redux-fun');
const updater = (action) => state => state;
const reducer = toReducer(updater);

Updaters


updater with initial state
const { withDefaultState } = require('redux-fun');

// normal
const updater_1 = withDefaultState({}, action => state => state);

// curried
const updater_2 = withDefaultState({})(action => state => state);

Middlewares


Compose middlewares
  const { composeMiddlewares, pipeMiddlewares } = require('redux-fun');

  const middleware_1 = composeMiddl(m3, m2, m1);
  const middleware_2 = pipeMiddlewares(m1, m2, m3);
Preserve async flow (deprecated)

Use preserveAsyncSeries instead

Preserve async series

Respect the dispatch order with async middleware

  const { preserveAsyncSeries } = require('redux-fun');
  const middleware_1 = preserveAsyncSeries('ACTION_TYPE')
  const middleware_2 = preserveAsyncSeries(['ACTION_TYPE_1', 'ACTION_TYPE_2'])

Selectors


Bind selectors
  const { bindSelectors } = require('redux-fun');

  const selectors = {
    getUsers: (state) => state.users,
    getUser: (state, { id }) => state.users[id],
  }

  const boundSelectors = bindSelectors(selectors, store.getState);
  const user = boundSelectors.getUser({ id: 1 });