-
Notifications
You must be signed in to change notification settings - Fork 3
/
types.ts
61 lines (50 loc) · 1.46 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import type { Instruction, Operation } from "./deps.ts";
export interface Computation<T = unknown> {
// deno-lint-ignore no-explicit-any
[Symbol.iterator](): Iterator<Instruction, T, any>;
}
export type Next = () => Operation<void>;
export type IdProp = string | number;
export type LoadingStatus = "loading" | "success" | "error" | "idle";
export interface LoaderItemState<
M extends Record<string, unknown> = Record<IdProp, unknown>,
> {
id: string;
status: LoadingStatus;
message: string;
lastRun: number;
lastSuccess: number;
meta: M;
}
export interface LoaderState<
M extends AnyState = AnyState,
> extends LoaderItemState<M> {
isIdle: boolean;
isLoading: boolean;
isError: boolean;
isSuccess: boolean;
isInitialLoading: boolean;
}
export type LoaderPayload<M extends AnyState> =
& Pick<LoaderItemState<M>, "id">
& Partial<Pick<LoaderItemState<M>, "message" | "meta">>;
// deno-lint-ignore no-explicit-any
export type AnyState = Record<string, any>;
// deno-lint-ignore no-explicit-any
export interface Payload<P = any> {
payload: P;
}
export interface Action {
type: string;
}
export type ActionFn = () => { toString: () => string };
export type ActionFnWithPayload<P = any> = (p: P) => { toString: () => string };
// https://github.com/redux-utilities/flux-standard-action
export interface AnyAction extends Action {
payload?: any;
meta?: any;
error?: boolean;
}
export interface ActionWithPayload<P> extends AnyAction {
payload: P;
}