Skip to main content

Actions

Actions are minimal descriptions of something that happened in the application.

They can be read and consumed by Manager middleware.

Many actions use the same meta information:

interface ActionMeta {
readonly fetchedAt: number;
readonly date: number;
readonly expiresAt: number;
}

FETCH

interface FetchMeta {
fetchedAt: number;
resolve: (value?: any | PromiseLike<any>) => void;
reject: (reason?: any) => void;
promise: PromiseLike<any>;
}

interface FetchAction {
type: typeof FETCH_TYPE;
endpoint: Endpoint;
args: readonly [...Parameters<Endpoint>];
key: string;
meta: FetchMeta;
}

Comes from Controller.fetch(), Controller.fetchIfStale(), useSuspense(), useDLE(), useLive(), useFetch()

SET

interface SetAction {
type: typeof SET_TYPE;
schema: Queryable;
args: readonly any[];
meta: ActionMeta;
value: {} | ((previousValue: Denormalize<Queryable>) => {});
}

Comes from Controller.set()

SET_RESPONSE

interface SetResponseAction {
type: typeof SET_RESPONSE_TYPE;
endpoint: Endpoint;
args: readonly any[];
key: string;
meta: ActionMeta;
response: ResolveType<Endpoint> | Error;
error: boolean;
}

Comes from Controller.setResponse(), NetworkManager

RESET

interface ResetAction {
type: typeof RESET_TYPE;
date: number;
}

Comes from Controller.resetEntireStore()

SUBSCRIBE

interface SubscribeAction {
type: typeof SUBSCRIBE_TYPE;
endpoint: Endpoint;
args: readonly any[];
key: string;
}

Comes from Controller.subscribe(), useSubscription(), useLive()

UNSUBSCRIBE

interface UnsubscribeAction {
type: typeof UNSUBSCRIBE_TYPE;
endpoint: Endpoint;
args: readonly any[];
key: string;
}

Comes from Controller.unsubscribe(), useSubscription(), useLive()

INVALIDATE

interface InvalidateAction {
type: typeof INVALIDATE_TYPE;
key: string;
}

Comes from Controller.invalidate()

INVALIDATEALL

interface InvalidateAllAction {
type: typeof INVALIDATEALL_TYPE;
testKey: (key: string) => boolean;
}

Comes from Controller.invalidateAll()

EXPIREALL

interface ExpireAllAction {
type: typeof EXPIREALL_TYPE;
testKey: (key: string) => boolean;
}

Comes from Controller.expireAll()