UNPKG

830 BTypeScriptView Raw
1export declare type Send = (type: string, payload: any) => void;
2export declare type On = (type: string) => Promise<any>;
3export interface Action {
4 type: string;
5 payload: any;
6}
7export interface Params {
8 state: Record<string, any>;
9 setState: (key: string, val: any) => void;
10}
11export interface State {
12 init: (params: Params) => Promise<any>;
13 update: (params: Params) => any;
14 close: (params: Params) => any;
15}
16export declare class DataServer {
17 private client?;
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}