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 actionTypes.FETCH;
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 actionTypes.SET;
schema: Queryable;
args: readonly any[];
meta: ActionMeta;
value: {} | ((previousValue: Denormalize<Queryable>) => {});
}
Comes from Controller.set()
SET_RESPONSE
interface SetResponseAction {
type: typeof actionTypes.SET_RESPONSE;
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 actionTypes.RESET;
date: number;
}
Comes from Controller.resetEntireStore()
SUBSCRIBE
interface SubscribeAction {
type: typeof actionTypes.SUBSCRIBE;
endpoint: Endpoint;
args: readonly any[];
key: string;
}
Comes from Controller.subscribe(), useSubscription(), useLive()
UNSUBSCRIBE
interface UnsubscribeAction {
type: typeof actionTypes.UNSUBSCRIBE;
endpoint: Endpoint;
args: readonly any[];
key: string;
}
Comes from Controller.unsubscribe(), useSubscription(), useLive()
INVALIDATE
interface InvalidateAction {
type: typeof actionTypes.INVALIDATE;
key: string;
}
Comes from Controller.invalidate()
INVALIDATEALL
interface InvalidateAllAction {
type: typeof actionTypes.INVALIDATEALL;
testKey: (key: string) => boolean;
}
Comes from Controller.invalidateAll()
EXPIREALL
interface ExpireAllAction {
type: typeof actionTypes.EXPIREALL;
testKey: (key: string) => boolean;
}
Comes from Controller.expireAll()