on() subscribes to a typed event and returns
an unsubscribe function. The event names are the keys of
"@railgun-reloaded/wallet-sdk/node".RailgunEventMap: sync:start, sync:progress, sync:complete,
sync:error, balance:update, and error.
const stop = client.on(
'balance:update',
({ walletId, chainId, balances, notesAdded, notesSpent }) => {
render(balances)
},
{ walletId, chainId: 8453 }
)
stop()
balance:update fires after decrypt() or sync() changes the notes of a
wallet. The payload is the full balance, not a delta.balance:update. Use
sync:complete to know that a run finished.error.
The method that caused the event does not fail.close() removes every subscriber.