Function useRealtime

  • Open a realtime subscription for the lifetime of the component and tear it down on unmount (StrictMode-safe: the effect's cleanup runs between the double-invoked mounts, so no duplicate subscriptions leak).

    factory should open the subscription and return its cleanup handle. It is re-run whenever deps change. Works with the SDK realtime store (store.connect(...) returns { close() }) or any () => void unsubscribe.

    Parameters

    • factory: undefined | null | (() => undefined | RealtimeCleanup)
    • deps: readonly unknown[] = []

    Returns void

    useRealtime(() => store.connect(transport, request), [transport, request]);