Skip to content
0

katanakit-js / useRunPool

Function: useRunPool() ​

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

Defined in: src/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 Parameters ​

Type ParameterDescription
TInputInput data type.
TOutputOutput data type.

Parameters ​

ParameterTypeDescription
keystringThe pool key created via useCreatePool.
dataTInputThe input data to pass to the pool's function.

Returns ​

Promise<TOutput>

A Promise resolving to the function's output.

Throws ​

If the pool does not exist.

Example ​

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

Released under the MIT License.