UNPKG

@hotmeshio/hotmesh

Version:

Permanent-Memory Workflows & AI Agents

30 lines (29 loc) 1.14 kB
/** * Pauses the workflow until a signal with the given `signalId` is received. * This method is commonly used to coordinate between the main workflow and hook functions, * or to wait for external events. * * @example * // Basic usage - wait for a single signal * const payload = await MemFlow.workflow.waitFor<PayloadType>('abcdefg'); * * @example * // Wait for multiple signals in parallel * const [signal1, signal2] = await Promise.all([ * MemFlow.workflow.waitFor<Record<string, any>>('signal1'), * MemFlow.workflow.waitFor<Record<string, any>>('signal2') * ]); * * @example * // Typical pattern with hook functions * // In main workflow: * await MemFlow.workflow.waitFor<ResponseType>('hook-complete'); * * // In hook function: * await MemFlow.workflow.signal('hook-complete', { data: result }); * * @template T - The type of data expected in the signal payload * @param {string} signalId - A unique signal identifier shared by the sender and receiver. * @returns {Promise<T>} The data payload associated with the received signal. */ export declare function waitFor<T>(signalId: string): Promise<T>;