@amityco/ts-sdk-react-native
Version:
Amity Social Cloud Typescript SDK
23 lines (21 loc) • 656 B
text/typescript
import { onConnectionError } from './onConnectionError';
/**
* ```js
* import { onClientDisconnected } from '@amityco/ts-sdk-react-native'
* const dispose = onClientDisconnected(() => {
* // ...
* })
* ```
*
* Fired when any {@link Amity.Client} have been disconnected
*
* @param callback The function to call when the event was fired
* @returns an {@link Amity.Unsubscriber} function to stop listening
*
* @category Client Events
*/
export const onClientDisconnected = (callback: Amity.Listener<void>): Amity.Unsubscriber => {
return onConnectionError(({ code }) => {
code === Amity.ClientError.DISCONNECTED && callback();
});
};