Interface: PollOptions\<T, A\>
Type Parameters
Section titled “Type Parameters”T
A = Record<string, unknown>
Properties
Section titled “Properties”attributes?
Section titled “attributes?”
optionalattributes?:A
Initial value for ctx.attributes. Defaults to {}. The same
object is reused across iterations, so callers can pre-populate
fields (timers, retry counters, etc.) and the producer /
predicate can mutate them in place.
filter?
Section titled “filter?”
optionalfilter?: ((value,ctx) =>boolean|PromiseLike<boolean>) |"distinct"
Predicate evaluated against each yielded value: return true to
keep it, false to skip it (without stopping the loop). May be
sync or async - a PromiseLike<boolean> is awaited before the
decision is made. Receives the same PollContext as the
producer (same signal, same attributes bag). The special
value "distinct" skips a value that deep-equals the previous
one.
intervalMs
Section titled “intervalMs”intervalMs:
number
Milliseconds to wait between polls.
predicate?
Section titled “predicate?”
optionalpredicate?: (value,ctx) =>boolean|PromiseLike<boolean>
Predicate evaluated against each yielded value: return true to
keep polling, false to stop. May be sync or async. Omit to poll
forever (the consumer stops by breaking out of the loop or by
aborting signal).
Parameters
Section titled “Parameters”T
PollContext<T, A>
Returns
Section titled “Returns”boolean | PromiseLike<boolean>
signal?
Section titled “signal?”
optionalsignal?:AbortSignal
External cancellation handle. Tied into the internal signal that
poll hands to producer, so aborting it tears down both the
in-flight request and the inter-poll sleep.
timeoutMs?
Section titled “timeoutMs?”
optionaltimeoutMs?:number
Hard upper bound on the total lifetime of the poll loop, in
milliseconds. When the budget elapses, poll aborts its internal
signal so the in-flight producer and inter-poll sleep both tear
down promptly, and the loop throws the TimeoutError
DOMException produced by AbortSignal.timeout(timeoutMs). The
budget starts ticking the moment the generator is created.