UNPKG

@hyper-fetch/core

Version:

Cache, Queue and Persist your requests no matter if you are online or offline!

54 lines 2.06 kB
import { default as EventEmitter } from 'events'; import { CacheValueType } from '.'; import { AdapterInstance } from '../adapter'; /** Create the cache event emitters and listeners for data changes, invalidation, and deletion. */ export declare const getCacheEvents: (emitter: EventEmitter) => { /** * Set cache data * @param data */ emitCacheData: <Response, Error, Adapter extends AdapterInstance>(data: CacheValueType<Response, Error, Adapter> & { cached: boolean; }, isTriggeredExternally?: boolean) => void; /** * Invalidate cache values event */ emitInvalidation: (cacheKey: string, isTriggeredExternally?: boolean) => void; /** * Delete of cache values */ emitDelete: (cacheKey: string, isTriggeredExternally?: boolean) => void; /** * Cache data listener for all keys * @param callback * @returns */ onData: <Response, Error, Adapter extends AdapterInstance>(callback: (data: CacheValueType<Response, Error, Adapter> & { cached: boolean; }) => void) => VoidFunction; /** * Cache data listener filtered by a specific cache key * @param cacheKey * @param callback * @returns */ onDataByKey: <Response, Error, Adapter extends AdapterInstance>(cacheKey: string, callback: (data: CacheValueType<Response, Error, Adapter>) => void) => VoidFunction; /** * Cache invalidation listener * @param callback * @returns */ onInvalidate: (callback: (cacheKey: string) => void) => VoidFunction; /** * Cache invalidation listener * @param cacheKey * @param callback * @returns */ onInvalidateByKey: (cacheKey: string, callback: () => void) => VoidFunction; /** Cache deletion listener for all keys */ onDelete: (callback: (cacheKey: string) => void) => VoidFunction; /** Cache deletion listener filtered by a specific cache key */ onDeleteByKey: (cacheKey: string, callback: () => void) => VoidFunction; }; //# sourceMappingURL=cache.events.d.ts.map