0

I have designed a payload dispatch which is generating a chirp but on the receiver side how can I incorporate onReceiving& onReceived events while decoding sound or chirp to my data in webpage

My Chirp Instantiation:

      var chirp = Chirp({
        key: CHIRP_APP_KEY,
        onReceiving: () => {
        this.setState({
          received: '...',
          disabled: true
        })
      },
        onReceived: data => {
          console.log('xyz')
          if (data.length > 0) {
            console.log(toAscii(data))
          } else {
            console.error('Decode failed')
          }
        }
      });

CHirp SDK invoke in wasm

        chirp.then(sdk => {
          console.log(sdk)
          sdk.start().then(() => {
          // sdk.onReceiving()
          })
        }).catch(console.error)

in this scenario how can I incorporate series of promises?

Tarun_vella
  • 71
  • 2
  • 5

1 Answers1

0

You can pass in any function to the ChirpSDK when instantiating, which are called when data has started/finished being received. These functions could do anything you like, such as dispatch an event. See https://developers.chirp.io/docs/getting-started/wasm

You can find an example using the Chirp WebAssembly SDK with a frontend framework such as React in this blog post - https://blog.chirp.io/chirp-in-react/

joextodd
  • 694
  • 4
  • 9