@data-client/core
Version:
Async State Management without the Management. REST, GraphQL, SSE, Websockets, Fetch
55 lines • 1.86 kB
TypeScript
import type { 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<Omit<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