mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-06 00:32:26 -08:00
ran formatter fixed lint issues, primarily getting rid of "any"s and swapping to .toSorted()
16 lines
455 B
TypeScript
16 lines
455 B
TypeScript
import type { ClientEventHandlerMap, MatrixClient } from '$types/matrix-sdk';
|
|
import { ClientEvent } from '$types/matrix-sdk';
|
|
import { useEffect } from 'react';
|
|
|
|
export const useSyncState = (
|
|
mx: MatrixClient | undefined,
|
|
onChange: ClientEventHandlerMap[ClientEvent.Sync]
|
|
): void => {
|
|
useEffect(() => {
|
|
mx?.on(ClientEvent.Sync, onChange);
|
|
return () => {
|
|
mx?.removeListener(ClientEvent.Sync, onChange);
|
|
};
|
|
}, [mx, onChange]);
|
|
};
|