redux-ws-middleware
Version:
This package makes web socket management much easier with redux
35 lines (34 loc) • 1.05 kB
TypeScript
import { SocketDispatch } from '../../services/Redux/ReduxService.types';
import { Options } from '../../services/WebSocket/WebSocketService.types';
export declare type ActionType = string | RegExp;
export declare type MiddlewareOptions<Req, Res, SReq = Req, DRes = Res> = Options<Req, Res, SReq, DRes> & {
actionTypes: [ActionType, ActionType, ActionType] | [ActionType, ActionType] | [ActionType];
completedActionTypes: [string, string];
};
export declare type CloseAction<T extends string = string> = {
type: T;
payload?: {
code?: number;
};
data?: {
code?: number;
};
code?: number;
};
export declare type ClosedAction<T extends string = string> = {
type: T;
payload: {
reason: string;
forceDisconnection: boolean;
code: number;
};
};
export declare type MiddlewareAPI<D extends SocketDispatch = SocketDispatch, S = unknown> = {
dispatch: D;
getState(): S;
};
export declare type SendAction<T, Req> = {
type: T;
payload?: Req;
data?: Req;
};