apollo-state-sync - API Reference (Users)
    Preparing search index...

    Type Alias RVarSyncedConfigType<T>

    Configuration options for syncing a reactive variable across browsing contexts.

    type RVarSyncedConfigType<T = unknown> = {
        shouldNotBroadcastFilter?: (
            newValue: T,
            prevValue: T,
            name: string,
            isDebounceTimerRunning: boolean,
        ) => boolean;
        shouldNotPersistFilter?: (
            newValue: T,
            prevValue: T,
            name: string,
        ) => boolean;
        skipDefaultComparison?: boolean;
    }

    Type Parameters

    • T = unknown

      The type of the value stored in the reactive variable.

    Index
    shouldNotBroadcastFilter?: (
        newValue: T,
        prevValue: T,
        name: string,
        isDebounceTimerRunning: boolean,
    ) => boolean

    Determines whether a reactive variable update should be broadcast to other browsing contexts.

    Type Declaration

      • (
            newValue: T,
            prevValue: T,
            name: string,
            isDebounceTimerRunning: boolean,
        ): boolean
      • Parameters

        • newValue: T

          The newly updated value of the reactive variable.

        • prevValue: T

          The previous value before the update.

        • name: string

          The identifier or name of the reactive variable.

        • isDebounceTimerRunning: boolean

          Indicates if a debounce timer is currently active for this variable.

        Returns boolean

        true if the update should not be broadcast to other contexts; otherwise, false.

    // Prevent broadcast loops when a variable is updated by GQL subscriptions.
    // Since WebSocket connections already notify other contexts about subscription updates directly, only
    // updates originating from standard GraphQL queries should trigger a local broadcast.
    shouldNotBroadcastFilter: (newValue, prevValue, name) => isFromSubscription(newValue)
    shouldNotPersistFilter?: (newValue: T, prevValue: T, name: string) => boolean

    Determines if the new value should skip persistence during an update.

    skipDefaultComparison?: boolean

    Set to true, to skip the default comparison between new and old reactive var values.

    By default, this comparison prevents broadcasting if the values are identical, which is necessary to avoid infinite back-and-forth broadcasting between browsing contexts.

    Do not set this to true, unless you pass a custom comparison function in shouldNotBroadcastFilter.