Skip to content

PromiEvents and how to implement them #3

@Jean-Lessa

Description

@Jean-Lessa

According to the Web3JS docs, some functions return something they call a "PromiEvent". Going by their words verbatim:

This “promiEvent” is a promise combined with an event emitter to allow acting on different stages of action on the blockchain, like a transaction. PromiEvents work like a normal promises with added on, once and off functions. This way developers can watch for additional events like on “receipt” or “transactionHash”.

As far as I've noticed, at least the following functions either use, return or depend on this type to work:

  • Contract::once()
  • Contract::events()
  • Contract::allEvents()
  • Contract::getPastEvents()
  • Eth::sendTransaction()
  • Eth::sendSignedTransaction()
  • Method::send()

So we have a "promise" part and an "event" part. I'm not sure about this but once we have both parts I'd imagine we could unite their usage in a custom class. The "promise" part is technically fulfilled by std::future, but I don't know what would fulfill the "event"/"listen to events coming from the blockchain" part (if there is anything that would even be able to do that, considering how "stiff" C++ is compared to Javascript in that sense).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions