import { EventIterable } from "./generator"; import { _ChannelInternal } from "./channel"; export declare class GeneratorBuilder implements IGeneratorBuilder { private channel; private generators; private completionCallbacks; private errorCallbacks; private restartAsyncError; private thisArgs; private restartMsTimeout; constructor(channel: _ChannelInternal); addGenerator(generatorFunc: () => Generator): this; addCompletionCallback(callback: (result?: any) => void): this; restartOnAsyncError(msTimeout?: number): this; addErrorCallback(callback: (error?: any) => void): this; bindThis(thisArg: any, ...argArray: any[]): this; run(): () => void; } export interface IGeneratorBuilder { /** * Invoke all added generators. Returns a function that when invoked, cancels all running generators */ run(): () => void; /** * Add a generator function to the current configuration to be invoked when `IGeneratorBuilder.run` is called * @param generatorFunc Generator function to invoke */ addGenerator(generatorFunc: (...args: any[]) => Generator): IGeneratorBuilder; /** * Add a callback function to invoke when all generators are run to completion * @param callback Function to invoke when all added generators are run to completion. If more than one generetor is added, then `result` will be an array */ addCompletionCallback(callback: (result?: any | any[]) => void): IGeneratorBuilder; /** * Add a callback function to invoke whenever a generator throws an uncaught exception * @param callback */ addErrorCallback(callback: (error?: any) => void): IGeneratorBuilder; /** * For all given generator functions, bind `thisArg` to the value of `this` and optionally has the specified initial parameters. * Subsequent calls to this function will override previous calls for this `IGeneratorBuilder` instance * @param thisArg An object to which the this keyword can refer inside all the generator functions. * @param argArray A list of arguments to be passed to all the generator functions. */ bindThis(thisArg: any, ...argArray: any[]): IGeneratorBuilder; /** * Restart generators when they throw an async error. An async error is any error after the current stack frame. Sync errors are not caught because restarting on sync errors * would result in infinite loops * @param msTimeout Restart failed generators after a timeout. Defaults to zero */ restartOnAsyncError(msTimeout?: number): IGeneratorBuilder; }