How to use the @dfuse/client.InboundMessageType.HEAD_INFO 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 / client-and-socket-notifications.ts View on Github external
const wsStream = await client.streamHeadInfo((message: InboundMessage) => {
    if (message.type === InboundMessageType.ERROR) {
      console.log("WebSocket stream error.", message.data)
      return
    }

    if (message.type === InboundMessageType.LISTENING) {
      console.log("WebSocket stream is now listening.")
    }

    if (message.type === InboundMessageType.HEAD_INFO) {
      console.log("WebSocket stream data.", JSON.stringify(message.data))

      // Mark latest location where we want to start back at
      wsStream.mark({ atBlockNum: message.data.head_block_num })
    }
  })
github dfuse-io / client-js / examples / reference / stream-head-info.ts View on Github external
const stream = await client.streamHeadInfo((message: InboundMessage) => {
    if (message.type === InboundMessageType.LISTENING) {
      console.log(prettifyJson(message.data))
      return
    }

    if (message.type === InboundMessageType.HEAD_INFO) {
      console.log(prettifyJson(message.data))
      return
    }
  })