Batcher
Batcher<
K,E,V> =object
Defined in: Core/Batcher.ts:27
Groups nearby key lookups into bulk requests and returns an outcome for each caller.
Duplicate keys share a lookup while they are queued. Results are not cached, so a lookup after dispatch can fetch the same key again, even if the previous request is still running.
Example
Section titled “Example”Type Parameters
Section titled “Type Parameters”K
E
V
Properties
Section titled “Properties”
readonlyflush: () =>Deferred<void>
Defined in: Core/Batcher.ts:65
Dispatches queued keys without waiting for the scheduled microtask or timer, then waits for queued and in-flight batches to finish. Work queued while waiting also delays completion.
Primarily used in unit tests or before transaction boundaries to guarantee deterministic batch execution.
Returns
Section titled “Returns”Deferred<void>
Batcher.load to enqueue individual lookups.
readonlyload: {(key):Deferred<Outcome<E,V,K>>; (key,signal):Deferred<Outcome<Aborted|E,V,K>>; }
Defined in: Core/Batcher.ts:36
Queues a key and immediately returns a Deferred of its lookup outcome.
An individual caller can cancel without affecting other callers in its batch.
Call Signature
Section titled “Call Signature”Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”Parameters
Section titled “Parameters”K
signal
Section titled “signal”AbortSignal
Returns
Section titled “Returns”Deferred<Outcome<Aborted | E, V, K>>
key
The key to look up.
signal
Optional AbortSignal to cancel this individual caller’s lookup.
Batcher.loadMany to coalesce multiple keys in a single call.
loadMany
Section titled “loadMany”
readonlyloadMany: {(keys):Deferred<readonlyOutcome<E,V,K>[]>; (keys,signal):Deferred<readonlyOutcome<Aborted|E,V,K>[]>; }
Defined in: Core/Batcher.ts:51
Queues multiple keys and returns their outcomes in input order.
Does not short-circuit: preserves discrete per-key outcomes (Ok, Missing, or Err)
for each requested key.
Call Signature
Section titled “Call Signature”Parameters
Section titled “Parameters”readonly K[]
Returns
Section titled “Returns”Deferred<readonly Outcome<E, V, K>[]>
Call Signature
Section titled “Call Signature”(
keys,signal):Deferred<readonlyOutcome<Aborted|E,V,K>[]>
Parameters
Section titled “Parameters”readonly K[]
signal
Section titled “signal”AbortSignal
Returns
Section titled “Returns”Deferred<readonly Outcome<Aborted | E, V, K>[]>
keys
The collection of keys to look up.
signal
Optional AbortSignal to cancel this caller’s lookup batch.
Batcher.load to look up an individual key.