import type { Operation } from "./types.js"; /** * A uniform integration type representing anything that can be evaluated * as a the parameter to {@link call}. * * {@link call} converts a `Callable` into an `Operation` which can then be used * anywhere within Effection. * * APIs that accept `Callable` values allow end developers to pass simple * functions without necessarily needing to know anything about Operations. * * @example * ```javascript * function hello(to: Callable): Operation { * return function*() { * return `hello ${yield* call(to)}`; * } * } * * await run(() => hello(() => "world!")); // => "hello world!" * await run(() => hello(async () => "world!")); // => "hello world!" * await run(() => hello(function*() { return "world!" })); // => "hello world!" * ``` * @since 3.0 */ export interface Callable | PromiseLike | unknown, TArgs extends unknown[] = []> { (...args: TArgs): T; } /** * Pause the current operation and evaluate an async function, plain * function, or operation function. The calling operation will be * resumed (or errored) once call is completed. * * `call()` is a uniform integration point for calling async functions, * generator functions, and plain functions. * * To call an async function: * * @example * ```typescript * export function googleSlowly(query: string) { * return call(async function() { * await new Promise(resolve => setTimeout(resolve, 2000)); * return await fetch("https://google.com"); * }); * } * ``` * * or a plain function: * * @example * ```javascript * yield* call(() => "a string"); * ``` * * The function will be invoked anew every time that the `call()` operation is evaluated. * * @param callable - the operation, promise, async function, generator function, * or plain function to call as part of this operation * * @returns an {@link Operation} that evaluates to the result of executing the function to completion * @since 3.0 */ export declare function call(fn: (...args: TArgs) => PromiseLike): Operation; export declare function call(fn: (...args: TArgs) => Operation): Operation; export declare function call(fn: (...args: TArgs) => T): Operation;