UNPKG

@data-client/core

Version:

Async State Management without the Management. REST, GraphQL, SSE, Websockets, Fetch

56 lines (55 loc) 1.94 kB
import { EntityPath } from '@data-client/normalizr'; import Controller from '../controller/Controller.js'; export declare class GCPolicy implements GCInterface { protected endpointCount: Map<string, number>; protected entityCount: Map<string, Map<string, number>>; protected endpointsQ: Set<string>; protected entitiesQ: EntityPath[]; protected intervalId: ReturnType<typeof setInterval>; protected controller: Controller; protected options: Required<Pick<GCOptions, Exclude<keyof GCOptions, 'expiresAt'>>>; constructor({ intervalMS, expiryMultiplier, expiresAt, }?: GCOptions); init(controller: Controller): void; cleanup(): void; createCountRef({ key, paths }: { key?: string; paths?: EntityPath[]; }): () => () => void; protected expiresAt({ fetchedAt, expiresAt, }: { expiresAt: number; date: number; fetchedAt: number; }): number; protected runSweep(): void; /** Calls the callback when client is not 'busy' with high priority interaction tasks * * Override for platform-specific implementations */ protected idleCallback(callback: (...args: any[]) => void, options?: IdleRequestOptions): void; } export declare class ImmortalGCPolicy implements GCInterface { init(): void; cleanup(): void; createCountRef(): () => () => undefined; } export interface GCOptions { intervalMS?: number; expiryMultiplier?: number; expiresAt?: (meta: { expiresAt: number; date: number; fetchedAt: number; }) => number; } export interface CreateCountRef { ({ key, paths }: { key?: string; paths?: EntityPath[]; }): () => () => void; } export interface GCInterface { createCountRef: CreateCountRef; init(controller: Controller): void; cleanup(): void; } //# sourceMappingURL=GCPolicy.d.ts.map