1 | export declare type Send = (type: string, payload: any) => void;
|
2 | export declare type On = (type: string) => Promise<any>;
|
3 | export interface Action {
|
4 | type: string;
|
5 | payload: any;
|
6 | }
|
7 | export interface Params {
|
8 | state: Record<string, any>;
|
9 | setState: (key: string, val: any) => void;
|
10 | }
|
11 | export interface State {
|
12 | init: (params: Params) => Promise<any>;
|
13 | update: (params: Params) => any;
|
14 | close: (params: Params) => any;
|
15 | }
|
16 | export declare class DataServer {
|
17 | private server?;
|
18 | private states;
|
19 | private state;
|
20 | constructor(server?: any, port?: number, host?: string);
|
21 | register(states: State[]): DataServer;
|
22 | init(): Promise<void>;
|
23 | listen(): Promise<void>;
|
24 | close(): Promise<void>;
|
25 | private handleConnection;
|
26 | private setState;
|
27 | private updateStateFile;
|
28 | }
|