Options for state-aware event subscriptions

interface StateAwareOptions<T> {
    getCurrentState: (() => T | Promise<T>);
    transformState?: ((state) => T);
    shouldUseFetchedState?: ((state) => boolean);
    timeout?: number;
}

Type Parameters

  • T

Properties

getCurrentState: (() => T | Promise<T>)

Function to fetch the current state

Type declaration

    • (): T | Promise<T>
    • Returns T | Promise<T>

transformState?: ((state) => T)

Optional transform function to normalize API response to event format

Type declaration

    • (state): T
    • Parameters

      • state: any

      Returns T

shouldUseFetchedState?: ((state) => boolean)

Optional function to determine if we should use the fetched state

Type declaration

    • (state): boolean
    • Parameters

      • state: T

      Returns boolean

timeout?: number

Timeout for waiting for events (ms)