How to use the @dfuse/client.dynamicMessageDispatcher function in @dfuse/client

To help you get started, we’ve selected a few @dfuse/client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dfuse-io / client-js / examples / advanced / never-miss-a-beat.ts View on Github external
public async start() {
    const dispatcher = dynamicMessageDispatcher({
      listening: this.onListening,
      action_trace: this.onAction,
      progress: this.onProgress
    })

    console.log("Engine starting")
    this.stream = await this.client.streamActionTraces(
      {
        accounts: "therealkarma",
        action_names: "transfer"
      },
      dispatcher,
      {
        // You can use the `with_progress` to be sure to commit
        // actions at least each 10 blocks. This is useful if your stream
        // is low traffic so you don't need to wait until the next
github dfuse-io / client-js / examples / advanced / navigating-forks.ts View on Github external
public async start() {
    console.log("Engine starting")
    this.stream = await this.client.streamTableRows(
      {
        code: "eosio",
        table: "global",
        scope: "eosio"
      },
      dynamicMessageDispatcher({
        listening: this.onListening,
        table_delta: this.onTableDelta,
        table_snapshot: this.onTableSnapshot,
        progress: this.onProgress
      }),
      {
        listen: true,
        fetch: true,
        // We use progress to display the current state of the table at a regular interval
        with_progress: 50
      }
    )
  }
github dfuse-io / client-js / examples / advanced / multiple-active-streams.ts View on Github external
"Notice how `Buy RAM` and `RAM cost` happens in random order, due to using 2 independent streams."
  )
  await waitFor(60000)
  await buyRamStream.close()
  await ramStream.close()

  console.log("")

  const mergedData = {
    accounts: "eosio|eosio.token",
    action_names: "buyrambytes|transfer",
    receivers: "eosio|eosio.token|eosio.ram"
  }
  const mergedStream: Stream = await client.streamActionTraces(
    mergedData,
    dynamicMessageDispatcher({
      listening: onListeningFactory("merged"),
      action_trace: onMergedAction
    })
  )

  console.log(
    "Notice how `Buy RAM` is always before `RAM cost` thanks to the strict ordering of a single stream."
  )
  await waitFor(60000)
  await mergedStream.close()

  client.release()
}