-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.d.ts
37 lines (30 loc) · 1008 Bytes
/
types.d.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
export declare type Subscription = (state: State, params: SubscriptionParams) => unknown;
export declare type Action = (state: State, payload: any, store : Store) => State | void;
export interface State {
[key: string]: any;
}
export interface Actions {
[key: string]: Action;
}
export interface SubscriptionParams {
action: string;
payload: object;
}
export interface Store {
getState(): State;
subscribe(fn: Subscription): Function;
dispatch(action: keyof Actions, payload?: object): Promise<unknown>;
patternMatch(mapfn: any): any;
destroy(): void;
}
export default function Oni(initialState: State, actions: Actions): Store;
interface useStoreInterface {
state: State;
payload: object;
action: keyof Actions;
dispatch(action: keyof Actions, payload?: object): Promise<unknown>;
}
export declare const createStore: (initialState: State, actions: Actions) => {
store: Store;
useStore(actions?: Array<keyof Actions>): useStoreInterface;
};