Skip to content

createEventWatcher ​

Import from: @xbbg/xnews

createEventWatcher<Provider>(source, options?): AsyncGenerator<EventWatcherResult<Provider>>

Defined in: src/events.ts (declaration: events.d.ts:54)

Polls a publisher and yields whenever an event first appears.

Every watcher result retains the full current state in snapshot/events and exposes only newly seen ids in addedEvents. This avoids both failure modes: replaying a week-long warning as new every five minutes, and making a consumer that replaces state from snapshot.events delete still-active warnings.

Remembered ids are bounded by maxSeenIds with oldest-first eviction. Failed polls are yielded once per distinct failure — consecutive identical failures are suppressed until a poll succeeds — matching the data lane. Polls with no unseen events yield nothing. The generator runs until signal aborts.

Type Parameters ​

Provider ​

Provider extends string

Parameters ​

source ​

EventSource<Provider>

options? ​

EventWatcherOptions

Returns ​

AsyncGenerator<EventWatcherResult<Provider>>

Last updated:

xbbg is independent open-source software and is not affiliated with, endorsed by, sponsored by, or approved by Bloomberg Finance L.P.