Skip to content

Commit

Permalink
feat: reinit when websocket close
Browse files Browse the repository at this point in the history
  • Loading branch information
yashim-deriv committed Jul 19, 2024
1 parent e1aff1f commit 79391fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/client-library/deriv-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
} from '../types/api.types';

type DerivAPIClientOptions = {
onOpen: (e: Event) => void;
onClose: (e: CloseEvent) => void;
onOpen?: (e: Event) => void;
onClose?: (e: CloseEvent) => void;
};

type DataHandler<T extends TSocketEndpointNames> = (data: TSocketResponseData<T>) => void;
Expand Down
4 changes: 3 additions & 1 deletion src/context/api-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { createContext, PropsWithChildren } from 'react';
import { URLUtils } from '@deriv-com/utils';
import { DerivAPIClient } from '../client-library/deriv-api-client';

export const derivAPIClient = new DerivAPIClient(URLUtils.getWebsocketURL());
export const derivAPIClient = new DerivAPIClient(URLUtils.getWebsocketURL(), {
onClose: () => window.location.reload(),
});

type APIData = {
derivAPIClient: DerivAPIClient;
Expand Down

0 comments on commit 79391fe

Please sign in to comment.