QubicTypeScript

subscribeAllEvents

Subscribes to every log type and yields fully decoded TypedEvents, with optional filter support.

Signature

subscribeAllEvents(
  bob: BobSubscriptionClient,
  filter?: EventFilter,
  options?: SubOptions,
): AsyncIterable<SubscriptionEvent<TypedEvent>>

Purpose

Subscribes to every log type and decodes each event. Apply a filter to narrow the stream. Use eventFilter() to build a typed filter with specific log types.

import { subscribeAllEvents, eventFilter, LOG_TYPE } from "@qubic.org/events"
import { createBobClient } from "@qubic.org/bob"

const bob = createBobClient({ baseUrl: "http://localhost:40420" })

const filter = eventFilter()
  .ofTypes(LOG_TYPE.BURNING, LOG_TYPE.DUST_BURNING)
  .build()

for await (const event of subscribeAllEvents(bob.subscription, filter)) {
  if (event.isCatchUp) continue

  const typed = event.data

  if (typed.logType === LOG_TYPE.BURNING) {
    console.log("Burned:", typed.data.amount, "QU from", typed.data.source)
  } else if (typed.logType === LOG_TYPE.DUST_BURNING) {
    console.log("Dust burn:", typed.data.burns.length, "accounts")
  }
}

Parameters

NameTypeDescription
bobBobSubscriptionClientSubscription client
filterEventFilterOptional filter including logTypes
options.startLogIdbigintResume from this log ID
options.startEpochnumberStart from the beginning of this epoch
options.signalAbortSignalStops the iteration when aborted

Returns

AsyncIterable<SubscriptionEvent<TypedEvent>> — switch on event.data.logType to narrow to specific event shapes.

Catch-up behavior

When a subscription starts or reconnects after a gap, Bob delivers buffered historical events before switching to live. These have isCatchUp: true.

Skip catch-up events when you only need live data:

for await (const event of subscribeAllEvents(bob.subscription)) {
  if (event.isCatchUp) continue
  // only live events
}

Process them when you want a complete history starting from a known point:

for await (const event of subscribeAllEvents(
  bob.subscription,
  undefined,
  { startEpoch: 150 },
)) {
  // isCatchUp: true until live; process all
  processEvent(event.data)
}

On this page