async onAsync()

Registers the listener function as callback of the selected RPC event.

Type

async onAsync(eventName, listener): void

Parameters

Name
Type
Description

eventName

String

Event to listen. Depeding on the provider chain one of Constellation RPC event or an Ethereum RPC event.

listener

()=>any

Callback function.

Return Type

void

Example

TypeScript

await provider.onAsync("accountsChanged", () => {
  // Do something when accounts changed
});

Last updated

Was this helpful?