matrix-js-sdk
    Preparing search index...

    Interface PollingCachedValueOptions<ValueType>

    How to fetch and cache a given value, as passed to PollingCachedValue.

    interface PollingCachedValueOptions<ValueType> {
        fetch: () => Promise<ValueType>;
        logger: Logger;
        name: string;
        onValueCached?: (value: ValueType) => void;
        shouldCacheError?: (error: unknown) => boolean;
        ttlMillis?: number;
    }

    Type Parameters

    • ValueType
    Index
    fetch: () => Promise<ValueType>

    Fetches a fresh value. Rejections are retried according to the retry policy.

    logger: Logger

    The logger to derive this value's child logger from.

    name: string

    The name of the cached value (for tracing/logs).

    onValueCached?: (value: ValueType) => void

    Called when a new value is cached. Use to emit changes if needed.

    shouldCacheError?: (error: unknown) => boolean

    Determines whether a non-transient error should be cached. By default errors are not cached, i.e. the next attempt retries the fetch.

    ttlMillis?: number

    The default time-to-live before the value gets refreshed, overridable per run via PollingCachedValue.start. If undefined the value never expires; use PollingCachedValue.refresh to clear the cache.