Files
Sable/src/app/hooks/useSyncState.ts
T
7w1 1717ca872f migrate to oxlint and oxfmt
ran formatter
fixed lint issues, primarily getting rid of "any"s and swapping to .toSorted()
2026-04-16 22:15:13 -05:00

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]);
};