UNPKG

use-stomp

Version:

react provider, class decorator, and a hook for websockets using the stomp protocol

44 lines (43 loc) 1.67 kB
import { StompNotification } from './useStompNotifications'; export declare type WebSocketWorkerProps = { onConnected?(): void; onDisconnected?(): void; onSyncState?(state: any): void; reconnectMaxAttempts?: number; reconnectInterval?: number; url?: string; }; export default class WebSocketWorker extends SharedWorker { _channels: {}; _connected: boolean; _id: string; _onConnected: () => void; _onDisconnected: () => void; _onSyncState: (state: any) => void; _syncChannels: {}; _syncMessages: {}; constructor(props?: WebSocketWorkerProps); connect: () => void; destroy: () => void; disconnect: () => void; testDisconnect: () => void; dismiss: (channel: any, id: any) => void; send: (channel: string, message: any) => void; setAuthHeader: (authHeader: any) => void; setHeader: (header: any) => void; setUrl: (url: any) => void; subscribe: (channel: string, callback: (message: any) => void) => (() => void); subscribeSync: (channel: string, callback: (messages: StompNotification<any>[], add: StompNotification<any>[], remove: StompNotification<any>[]) => void) => (() => void); unsubscribe: (channel: any) => void; unsubscribeSync: (channel: any) => void; _onMessage: (event: any) => void; _register: (props: Pick<WebSocketWorkerProps, 'reconnectMaxAttempts' | 'reconnectInterval'>) => void; _setError: (event: any) => void; _setVisibility: () => void; _setMessage: (event: any) => void; _setConnection: (event: any) => void; _unregister: () => void; _workerEvents: { [x: string]: (event: any) => void; }; }