Hiyve Components - v1.0.0
    Preparing search index...

    Interface UseRelaySnapshotExchangeOptions<TState>

    interface UseRelaySnapshotExchangeOptions<TState> {
        applySnapshot: (state: TState, fromUserId: string) => void;
        buildSnapshot: () => TState;
        enabled?: boolean;
        localUserId: string;
        requestJitterMs?: number;
        topicPrefix: string;
    }

    Type Parameters

    • TState
    Index

    Properties

    applySnapshot: (state: TState, fromUserId: string) => void

    Called for every snapshot the local peer receives in response to its own request. Expected to be idempotent — multiple peers may answer the same request.

    buildSnapshot: () => TState

    Returns the current snapshot to send when another peer asks for state. Called inside an effect after the deterministic jitter has elapsed, so it sees the latest committed state.

    enabled?: boolean

    Disable when the consumer hasn't initialised state yet (e.g. the file id isn't known). The hook becomes a no-op while disabled.

    true
    
    localUserId: string

    Local user's id. Used to address responses and apply jitter.

    requestJitterMs?: number

    Maximum jitter window (ms) before answering a state-request. Each peer picks a deterministic offset within this window based on a hash of its localUserId, so the peer set fans out responses instead of stampeding the requester.

    250
    
    topicPrefix: string

    Base topic for this protocol's state exchange. Two topics are derived: ${topicPrefix}.state-request and ${topicPrefix}.state-response. Use the same prefix the protocol's other relay topics share, e.g. 'hiyve.annotations' or 'hiyve.collab.polls'.