import { IGenerator } from "./_types/IGenerator"; import { Field, IDataHook } from "model-react"; /** * A class used to extract items from a (custom) generator */ export declare class GeneratorStreamExtractor { protected generator: IGenerator; protected itemCallback: (item: T) => void; protected started: Field; protected paused: Field; protected stopped: Field; protected sentStopSignal: boolean; protected pausedItem: T | null; protected continueExtraction: ((stopped: boolean) => void) | null; protected resolveStart: null | (() => void); protected generatorResult: Promise; /** * Creates a new generator extractor which extract a continuous stream of items * @param generator The generator to extract the items from * @param itemCallback The callback to forward the extracted items to */ constructor(generator: IGenerator, itemCallback: (item: T) => void); /** * Starts extracting items from the generator, or continues when paused * @returns A promise that resolves when extraction finished or was stopped */ start(): Promise; /** * Pauses item extraction, which may be continued later */ pause(): void; /** * Stops item extraction, which can't be continued later */ stop(): void; /** * Retrieves whether the item extraction has started * @param hook The hook to subscribe to changes * @returns Whether started */ hasStarted(hook?: IDataHook): boolean; /** * Retrieves whether item extraction has been paused * @param hook The hook to subscribe to changes * @returns Whether paused */ isPaused(hook?: IDataHook): boolean; /** * Retrieves whether all items were extracted from the generator * @param hook The hook to subscribe to changes * @returns Whether the generator extracted all items, or the extractor was stopped */ hasFinished(hook?: IDataHook): boolean; } //# sourceMappingURL=GeneratorStreamExtractor.d.ts.map