🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

redux-fsa

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-fsa

Flux Standard Action utlities for Redux

latest
Source
npmnpm
Version
0.4.0
Version published
Maintainers
1
Created
Source

redux-fsa

build status npm version

Flux Standard Action utilities for Redux.

npm install --save redux-fsa

createAction(type, actionCreator)

Wraps an action creator so that its return value is the payload of a Flux Standard Action. If no action creator is passed, or if the action creator is not a function, the identity function is used.

Example:

let increment = createAction('INCREMENT', amount => amount);
// same as
increment = createAction('INCREMENT');

expect(increment(42)).to.deep.equal({
  type: 'INCREMENT',
  payload: 42
});

handleAction(type, reducer | reducerMap)

Wraps a reducer so that only handles Flux Standard Actions of a certain type.

If a single reducer is passed, it is used to handle both successful and failed actions. You can use this form if you know a certain action will always be a success, like the increment example above.

Otherwise, you can specify reducers for success and error:

handleAction('FETCH_DATA', {
  success(state, action) {...}
  error(state, action) {...}
});

handleActions(reducerMap, ?defaultState)

Creates multiple reducers using handleAction() and combines them into a single reducer that handles multiple actions. Accepts a map where the keys are the passed as the first parameter to handleAction() (the action type), and the values are passed as the second parameter (either a reducer or reducer map).

The optional second parameter specifies a default or initial state, which is used when undefined is passed to the reducer.

(Internally, handleActions() works by applying multiple reducers in sequence using reduce-reducers.)

Example:

const reducer = handleActions({
  INCREMENT: (state, action) => ({
    counter: state.counter + amount.
  }),

  DECREMENT: ({ counter }, { payload: amount }) => ({
    counter: counter - amount
  })
}, { counter: 0 });

Suggested libraries

Use redux-fsa in combination with FSA-compliant libraries.

  • redux-promise - Promise middleware

Keywords

flux

FAQs

Package last updated on 02 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts