That's my logo
HomeGetting StartedType ReferenceActionAsyncActionActionReducerMapActionReducerActionCreatorAPI Reference
Examples
Readme

Type Reference: Core

Action

Represent a Flux Standard Action (FSA) where the generic type T represents the action's payload

interface Action<T = void> {
type: string;
payload: T;
}

AsyncAction

AsyncAction is both an ActionCreator (of payload type TPayload) and an object with nested action-creators.

Those nested action-creators handle failable async workflows with request, success and failure.

AsyncAction is better used in conjuction with Sagas


request(void): is dispatched imediately after a saga that handles an async action starts

success(payload: TResult): is dispatched on a successful response from an api, and takes a payload of type TResult

failure(payload: TError): is dispatched if an exception is throw, takes a payload of type TError

interface AsyncAction<TResult, TPayload = void, TError = Error>
extends ActionCreator<TPayload> {
request: ActionCreator;
success: ActionCreator<TResult>;
failure: ActionCreator<Error>;
}

ActionReducerMap

interface ActionReducerMap<TState> {
[key: string]: ActionReducer<TState, any>;
}

ActionReducer

type ActionReducer<TState, TPayload> = (
state: TState,
payload: TPayload
) => TState;

ActionCreator

interface ActionCreator<TPayload = void> {
(): Action;
(payload: TPayload): Action<TPayload>;
type: string;
reduce: <TState>(
reducer: ActionReducer<TState, TPayload>
) => {
[key: string]: ActionReducer<TState, TPayload>;
};
}