/** * Reactive wrappers around reusable concurrency primitives. * * @module bquery/concurrency */ import type { CreateRpcPoolOptions, CreateRpcWorkerOptions, CreateTaskPoolOptions, CreateTaskWorkerOptions, ReactiveRpcPool, ReactiveRpcWorker, ReactiveTaskPool, ReactiveTaskWorker, WorkerRpcHandlers, WorkerTaskHandler } from './types'; /** * Creates a reactive wrapper around a reusable task worker. * * The returned wrapper preserves the standard `run()` / `terminate()` API and * adds readonly signals such as `state$` and `busy$` for UI bindings. * * @example * ```ts * import { createReactiveTaskWorker } from '@bquery/bquery/concurrency'; * import { effect } from '@bquery/bquery/reactive'; * * const worker = createReactiveTaskWorker((value: number) => value * 2); * * effect(() => { * console.log(worker.state$.value, worker.busy$.value); * }); * * await worker.run(21); * worker.terminate(); * ``` */ export declare function createReactiveTaskWorker(handler: WorkerTaskHandler, options?: CreateTaskWorkerOptions): ReactiveTaskWorker; /** * Creates a reactive wrapper around a reusable RPC worker. * * The returned wrapper preserves the standard `call()` / `terminate()` API and * adds readonly signals such as `state$` and `busy$` for UI bindings. * * @example * ```ts * import { createReactiveRpcWorker } from '@bquery/bquery/concurrency'; * import { effect } from '@bquery/bquery/reactive'; * * const rpc = createReactiveRpcWorker({ * sum: ({ values }: { values: number[] }) => values.reduce((total, value) => total + value, 0), * }); * * effect(() => { * console.log(rpc.state$.value, rpc.busy$.value); * }); * * await rpc.call('sum', { values: [1, 2, 3] }); * rpc.terminate(); * ``` */ export declare function createReactiveRpcWorker(handlers: TRoutes, options?: CreateRpcWorkerOptions): ReactiveRpcWorker; /** * Creates a reactive wrapper around a reusable task pool. * * The returned wrapper preserves the standard `run()` / `clear()` / * `terminate()` API and adds readonly signals for pool state and queue load. * * @example * ```ts * import { createReactiveTaskPool } from '@bquery/bquery/concurrency'; * import { effect } from '@bquery/bquery/reactive'; * * const pool = createReactiveTaskPool((value: number) => value * 2, { concurrency: 2 }); * * effect(() => { * console.log(pool.pending$.value, pool.size$.value, pool.state$.value); * }); * * await Promise.all([pool.run(1), pool.run(2), pool.run(3)]); * pool.terminate(); * ``` */ export declare function createReactiveTaskPool(handler: WorkerTaskHandler, options?: CreateTaskPoolOptions): ReactiveTaskPool; /** * Creates a reactive wrapper around a reusable RPC pool. * * The returned wrapper preserves the standard `call()` / `clear()` / * `terminate()` API and adds readonly signals for pool state and queue load. * * @example * ```ts * import { createReactiveRpcPool } from '@bquery/bquery/concurrency'; * import { effect } from '@bquery/bquery/reactive'; * * const pool = createReactiveRpcPool( * { * sum: ({ values }: { values: number[] }) => values.reduce((total, value) => total + value, 0), * }, * { concurrency: 2 } * ); * * effect(() => { * console.log(pool.pending$.value, pool.size$.value, pool.state$.value); * }); * * await Promise.all([ * pool.call('sum', { values: [1, 2] }), * pool.call('sum', { values: [3, 4] }), * pool.call('sum', { values: [5, 6] }), * ]); * * pool.terminate(); * ``` */ export declare function createReactiveRpcPool(handlers: TRoutes, options?: CreateRpcPoolOptions): ReactiveRpcPool; //# sourceMappingURL=reactive.d.ts.map