Edit page

API Reference

createActionCreator(type[, executor])

Creates an action creator.

Arguments

  1. type (string ): the type of action being created. It should typically be defined as string constants and is the only required parameter.
  2. executor (Function ): a function that gives an argument named resolve that gives payload and meta as optional arguments and returns an action.

Returns

(ActionCreator )

Examples

With only type:

With type and payload:

With type and meta:

With type, payload and meta:

createAction(type[, executor])

Alias of createActionCreator.

createReducer(defaultState, handlerMapsCreator)

Creates a reducer.

Arguments

  1. defaultState (any ): returning state when undefined is passed to the created reducer.
  2. handlerMapsCreator (Function ): a function that gives an argument named handleAction that gives action creator(s) and handler as arguments and returns a HandlerMap.

Returns

(Reduer ).

Examples

Basic:

Handle multiple actions in one handler:

getType(actionCreator)

Get wrapped action type of an action creator.

Arguments

  1. actionCreator (ActionCreator ): an action creator.

Returns

(string ). The action type that the action creator wraps.

Example

ofType(keys)

An RxJS operator that filters input actions according to the given action creator(s) or action(s) or action type(s).

Arguments

  1. keys (ActionCreator[] | Action[] | string[] ):

Examples

With action creator:

With multiple action creators:

With action:

With action type:

Action<Type, Payload, Meta>

A type that creates Flux-standard compliant action.

AnyAction

(Action<string> ).

ActionType<T>

A type that infers action from (ActionCreator ) or (Reducer ).

DeepImmutable<T>

A type which gives any type as input and return corresponding deeply immutable data structure as output.

DeepImmutableObject<T>

A type which gives an object type as input and return corresponding deeply immutable data structure as output.

DeepImmutableMap<T>

A type which gives a Map type as input and return corresponding deeply immutable data structure as output.

DeepImmutableArray<T>

A type which gives an Array type as input and return corresponding **deeply immutable data structure as output.

Immutable<T>

A type which gives any type as input and return corresponding shallowly immutable data structure as output.