Interface AsyncResourceContext<T>

interface AsyncResourceContext<T> {
    abort: AbortSignal;
    current: null | T;
    currentExpiresAt: number;
    currentFetchedAt: number;
    isBackground: boolean;
}

Type Parameters

  • T

Properties

abort: AbortSignal

abort signal that should be used to abort the fetch

current: null | T

currently cached value of the resource

currentExpiresAt: number

performance.now() when the resource will/did expire

currentFetchedAt: number

performance.now() when the resource was fetched

isBackground: boolean

whether the current fetch was initiated in the background (by the swr mechanism or because of auto-reload). this can be used to prioritize the fetch if needed