UNPKG

@magnetarjs/core

Version:
35 lines (34 loc) 1.24 kB
import type { DocMetadata, DoOnFetch, EventFnBefore, EventFnSuccess, OnAddedFn, OnModifiedFn, OnRemovedFn, PluginModuleConfig, StreamEvent } from '@magnetarjs/types'; /** * Context needed to execute stream event functions */ type StreamEventContext = { collectionPath: string; docId: string; path: string; pluginModuleConfig: PluginModuleConfig; storeName: string; streamEvent: StreamEvent; }; /** * Event functions to execute before/after cache insertion */ type StreamEventFns = { before: EventFnBefore[]; success: EventFnSuccess[]; }; /** * Executes given function array with given args-array deconstructed, it will always use replace the first param with whatever the response of each function was. */ export declare function executeOnFns<Payload extends { [key: string]: any; } | string | undefined>(params: { modifyReadResultFns: (OnAddedFn | OnModifiedFn | OnRemovedFn)[]; cacheStoreFns: (DoOnFetch | OnAddedFn | OnModifiedFn | OnRemovedFn)[]; payload: Payload; docMetaData: DocMetadata; /** Optional: event functions and context for per-document stream events */ eventFns?: StreamEventFns; eventContext?: StreamEventContext; }): Payload | undefined; export {};