platform-bible-react
    Preparing search index...

    Type Alias EventSeededStateOptions<T>Experimental

    Options for useEventSeededState.

    This type is unstable and may change or disappear without notice

    type EventSeededStateOptions<T> = {
        enabled?: boolean;
        event: PlatformEvent<unknown> | undefined;
        isValid: (value: unknown) => value is T;
        read: () => Promise<unknown>;
        recheckIntervalMs?: number;
        seedRetries?: number;
        seedRetryDelayMs?: number;
        shouldRecheck?: (value: T | undefined) => boolean;
    }

    Type Parameters

    • T
    Index

    Properties

    enabled?: boolean

    Whether to track the value at all. While false the value is reset to undefined, nothing is read and emitted events are ignored. Defaults to true.

    This option is unstable and may change or disappear without notice

    event: PlatformEvent<unknown> | undefined

    The event that announces new values, or undefined while it is not yet available. An emitted payload that isValid rejects is ignored.

    This option is unstable and may change or disappear without notice

    isValid: (value: unknown) => value is T

    Whether a payload from read or event is a well-formed value.

    WARNING: MUST BE STABLE - const or wrapped in useCallback. A reference that is updated every render restarts the seed every render.

    This option is unstable and may change or disappear without notice

    read: () => Promise<unknown>

    Reads the current value. Rejects if the read fails. An answer that isValid rejects is ignored.

    WARNING: MUST BE STABLE - const or wrapped in useCallback. A reference that is updated every render restarts the seed every render.

    This option is unstable and may change or disappear without notice

    recheckIntervalMs?: number

    Milliseconds between re-reads while shouldRecheck holds for the current value. Leave undefined to never re-read on a timer.

    This option is unstable and may change or disappear without notice

    seedRetries?: number

    How many times a rejected seed read is retried. Defaults to 10.

    This option is unstable and may change or disappear without notice

    seedRetryDelayMs?: number

    Milliseconds to wait between seed retries. Defaults to 3000.

    This option is unstable and may change or disappear without notice

    shouldRecheck?: (value: T | undefined) => boolean

    Whether to re-read every recheckIntervalMs, given the current value, or undefined while none is known. Use it when the value may be stale in a way the event will not correct. Defaults to never. A failed or invalid seed is recovered by an event, or by the recheck if this returns true for undefined.

    This option is unstable and may change or disappear without notice