import { Operation, OperationFunction } from '../operation'; import type { Task, TaskOptions } from '../task'; interface Spawn extends OperationFunction> { within(scope: Task): Operation>; } /** * An operation which spawns the given operation as a child of the current task. * * You should prefer using the spawn operation over calling `task.run` from * within Effection code. The reason being that a synchronous failure in the * spawned task will not be caught until the next yield point when using `run`, * which can be confusing. Additionally, using `spawn` is usually more * ergonomic. * * ### Example * * ```typescript * import { main, sleep, spawn } from 'effection'; * * main(function*() { * yield spawn(function*() { * yield sleep(1000); * console.log("hello"); * }); * yield spawn(function*() { * yield sleep(2000); * console.log("world"); * }); * yield; * }); * ``` * * @param operation the operation to run as a child of the current task * @typeParam T the type that the spawned task evaluates to */ export declare function spawn(operation?: Operation, options?: TaskOptions): Spawn; export {}; //# sourceMappingURL=spawn.d.ts.map