Skip to content

UseRunPool

katanakit-js / useRunPool

function useRunPool<TInput, TOutput>(key, data): Promise<TOutput>;

Defined in: infrastructure/worker/worker.service.ts:185

Runs a task on an existing Worker pool. Tasks are correlated by __taskId so concurrent tasks do not stomp each other’s handlers.

Type Parameter Description
TInput Input data type.
TOutput Output data type.
Parameter Type Description
key string The pool key created via useCreatePool.
data TInput The input data to pass to the pool’s function.

Promise<TOutput>

A Promise resolving to the function’s output.

If the pool does not exist.

useCreatePool("math", (n: number) => n * 10);
const result = await useRunPool("math", 5); // 50