@hyper-fetch/core
Version:
Cache, Queue and Persist your requests no matter if you are online or offline!
66 lines • 6.44 kB
TypeScript
import { default as EventEmitter } from 'events';
import { RequestEventType, RequestLoadingEventType, RequestProgressEventType, RequestResponseEventType, RequestRemovedEventType, RequestDeduplicatedEventType } from '..';
import { AdapterInstance } from '../../adapter';
import { RequestInstance } from '../../request';
import { Client } from '../../client';
import { ExtendRequest } from '../../types';
/** Create event emitters and listeners for the request lifecycle: loading, progress, response, abort, deduplication, and removal. */
export declare const getRequestManagerEvents: (emitter: EventEmitter) => {
/**
* Emitters
*/
/** Emit when a request is deduplicated (skipped because an identical one is in-flight) */
emitDeduplicated: (data: RequestDeduplicatedEventType<RequestInstance>, isTriggeredExternally?: boolean) => void;
/** Emit loading state changes for a request */
emitLoading: (data: RequestLoadingEventType<RequestInstance>, isTriggeredExternally?: boolean) => void;
/** Emit when a request starts being sent */
emitRequestStart: (data: RequestEventType<RequestInstance>, isTriggeredExternally?: boolean) => void;
/** Emit when the response starts being received */
emitResponseStart: (data: RequestEventType<RequestInstance>, isTriggeredExternally?: boolean) => void;
/** Emit upload progress updates */
emitUploadProgress: (data: RequestProgressEventType<RequestInstance>, isTriggeredExternally?: boolean) => void;
/** Emit download progress updates */
emitDownloadProgress: (data: RequestProgressEventType<RequestInstance>, isTriggeredExternally?: boolean) => void;
/** Emit when a response is received */
emitResponse: <Adapter extends AdapterInstance>(data: RequestResponseEventType<ExtendRequest<RequestInstance, {
client: Client<any, Adapter>;
}>>, isTriggeredExternally?: boolean) => void;
/** Emit when a request is aborted */
emitAbort: (data: RequestEventType<RequestInstance>, isTriggeredExternally?: boolean) => void;
/** Emit when a request is removed from the dispatcher queue */
emitRemove: (data: RequestRemovedEventType<RequestInstance>, isTriggeredExternally?: boolean) => void;
/**
* Listeners
*/
/** Listen for deduplicated request events */
onDeduplicated: <T extends RequestInstance>(callback: (data: RequestDeduplicatedEventType<T>) => void) => VoidFunction;
onDeduplicatedByQueue: <T extends RequestInstance>(queryKey: string, callback: (data: RequestDeduplicatedEventType<T>) => void) => VoidFunction;
onDeduplicatedByCache: <T extends RequestInstance>(cacheKey: string, callback: (data: RequestDeduplicatedEventType<T>) => void) => VoidFunction;
onDeduplicatedById: <T extends RequestInstance>(requestId: string, callback: (data: RequestDeduplicatedEventType<T>) => void) => VoidFunction;
onLoading: <T extends RequestInstance>(callback: (data: RequestLoadingEventType<T>) => void) => VoidFunction;
onLoadingByQueue: <T extends RequestInstance>(queryKey: string, callback: (data: RequestLoadingEventType<T>) => void) => VoidFunction;
onLoadingByCache: <T extends RequestInstance>(cacheKey: string, callback: (data: RequestLoadingEventType<T>) => void) => VoidFunction;
onLoadingById: <T extends RequestInstance>(requestId: string, callback: (data: RequestLoadingEventType<T>) => void) => VoidFunction;
onRequestStart: <T extends RequestInstance>(callback: (details: RequestEventType<T>) => void) => VoidFunction;
onRequestStartByQueue: <T extends RequestInstance>(queryKey: string, callback: (details: RequestEventType<T>) => void) => VoidFunction;
onRequestStartById: <T extends RequestInstance>(requestId: string, callback: (details: RequestEventType<T>) => void) => VoidFunction;
onResponseStart: <T extends RequestInstance>(callback: (details: RequestEventType<T>) => void) => VoidFunction;
onResponseStartByQueue: <T extends RequestInstance>(queryKey: string, callback: (details: RequestEventType<T>) => void) => VoidFunction;
onResponseStartById: <T extends RequestInstance>(requestId: string, callback: (details: RequestEventType<T>) => void) => VoidFunction;
onUploadProgress: <T extends RequestInstance = RequestInstance>(callback: (data: RequestProgressEventType<T>) => void) => VoidFunction;
onUploadProgressByQueue: <T extends RequestInstance = RequestInstance>(queryKey: string, callback: (data: RequestProgressEventType<T>) => void) => VoidFunction;
onUploadProgressById: <T extends RequestInstance = RequestInstance>(requestId: string, callback: (data: RequestProgressEventType<T>) => void) => VoidFunction;
onDownloadProgress: <T extends RequestInstance = RequestInstance>(callback: (data: RequestProgressEventType<T>) => void) => VoidFunction;
onDownloadProgressByQueue: <T extends RequestInstance = RequestInstance>(queryKey: string, callback: (data: RequestProgressEventType<T>) => void) => VoidFunction;
onDownloadProgressById: <T extends RequestInstance = RequestInstance>(requestId: string, callback: (data: RequestProgressEventType<T>) => void) => VoidFunction;
onResponse: <T extends RequestInstance>(callback: (data: RequestResponseEventType<T>) => void) => VoidFunction;
onResponseByCache: <T extends RequestInstance>(cacheKey: string, callback: (data: RequestResponseEventType<T>) => void) => VoidFunction;
onResponseById: <T extends RequestInstance>(requestId: string, callback: (data: RequestResponseEventType<T>) => void) => VoidFunction;
onAbort: <T extends RequestInstance = RequestInstance>(callback: (request: RequestEventType<T>) => void) => VoidFunction;
onAbortByKey: <T extends RequestInstance = RequestInstance>(abortKey: string, callback: (request: RequestEventType<T>) => void) => VoidFunction;
onAbortById: <T extends RequestInstance = RequestInstance>(requestId: string, callback: (data: RequestEventType<T>) => void) => VoidFunction;
onRemove: <T extends RequestInstance = RequestInstance>(callback: (data: RequestRemovedEventType<T>) => void) => VoidFunction;
onRemoveByQueue: <T extends RequestInstance = RequestInstance>(queryKey: string, callback: (data: RequestRemovedEventType<T>) => void) => VoidFunction;
onRemoveById: <T extends RequestInstance = RequestInstance>(requestId: string, callback: (data: RequestRemovedEventType<T>) => void) => VoidFunction;
};
//# sourceMappingURL=request.manager.events.d.ts.map