ethjs / ethjs-contract

A simple contract object for the Ethereum RPC layer.
MIT License
20 stars 28 forks source link

RFC: Integrate eth-block-tracker for subscribable queries #2

Open danfinlay opened 7 years ago

danfinlay commented 7 years ago

Feature Proposal

Description

What if ethjs queries returned promEvents, somewhat like Web3@1.0 plans to have.

In addition to calling .then() on a result, you could subscribe to updates. Imagine:

token.balanceOf(my_address).on('latest', updateBalanceView)

Should be easier than ever with eth-block-tracker.

SilentCicero commented 7 years ago

oooooo. We can do this. But I would make in it's own module, and have hooks for it in different modules.

danfinlay commented 7 years ago

Yeah maybe it could be like ethjs-event-contract, and its initialization takes an ethjs-contract and an eth-block-tracker, and allows subscribing to updates on any property constant function of that contract, as well as maybe access to a synchronous property cache, of last-retrieved values?

SilentCicero commented 7 years ago

Yes, that could work and would reduce bulk/module complexity on the main contract object.