import { DataCache } from './DataCache'; import { DataStoreToken } from './DataStoreToken'; export interface SubscriptionProxy { (name: keyof Compartments): Promise; } export interface DataCacheScenario { cache: DataCache; /** * Provides strongly typed access to the value of the underlying compartment. */ createProxy: SubscriptionProxy; waitForAllCompartments: () => Promise; } /** * A helper function for creating a testing scenario. * @param policy The policy to configure the cache. * @returns Encapsulates the cache and a few helpers for controlling and accessing data for testing purposes. * @example * const a: ResponseA[] = []; * const b: ResponseB[] = []; * * const { createProxy } = createDataCacheScenario({ * a: { * source: new ConfiguredDataSource(async () => a), * defaultValue: [], * }, * b: { * source: new ConfiguredDataSource(async () => b), * defaultValue: [], * }, * }); * * const observedA = await createProxy('a'); * expect(observedA).toStrictEqual(a); * * const observedB = await createProxy('b'); * expect(observedB).toStrictEqual(b); */ export declare function createDataCacheScenario>(token: DataStoreToken, policy: Compartments): DataCacheScenario; export declare class Latch { private readonly semaphore; get isLatched(): boolean; execute(action: () => Promise): Promise; }