Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (next: *): * => (action: *): * => {
const { type }: * = action
if (type === CONNECT && !wsClient) {
const {
options,
handlers,
url,
protocols,
disconnectionTimeout = 0
}: ConnectionPayload = (action.payload: any)
wsClient = new SubscriptionClient(url, options, null, protocols)
handlerMap.onConnected = wsClient.onConnected(() => {
dispatchQueuedActions()
if (
handlers &&
typeof handlers.onConnected === 'function'
) {
dispatch(handlers.onConnected())
}
})
if (handlers) {
if (typeof handlers.onConnecting === 'function') {
handlerMap.onConnecting = wsClient.onConnecting(
(): * => {
if (disconnectionTimeoutId) {
clearTimeout(disconnectionTimeoutId)