Callbacks Promises Events
Last updated
Was this helpful?
Last updated
Was this helpful?
To help web3 integrate into all kind of projects with different standards, we provide multiple ways to act on asynchronous functions.
Most web3.js objects allow a callback as the last parameter, as well as returning promises to chain functions.
Meter as a blockchain has different levels of finality and therefore needs to return multiple "stages" of an action.
To cope with this requirement, we return a "PromiEvent" for functions like or contract methods. These stages are encapsulated into a "PromiEvent", which combines a promise with an event emitter.
The event emitter fires an event for each of the finality stages.
An example of a function that benefits from a PromiEvent is the method: