trufflesuite / drizzle

Reactive Ethereum dapp UI suite
905 stars 235 forks source link

Polls->account: intempestive refresh #48

Open eloudsa opened 4 years ago

eloudsa commented 4 years ago

Hi

I'm using Drizzle 1.5 on a React 16.10 project using hooks. I want to easily detect account's switches on Metamask in order to properly update my Dapp with the data retrieved from my contract for the current account. When I use a polls on account, I saw intempestive refresh of my component even if my account has not changed.

Do you have any clue (or sample) showing how to use this polls->account options properly on a React hooks project without comprimising the performance of the app?

For example, Metamask offers to listen for some events like network or account changes: ethereum.on('accountsChanged', function (accounts) { // Time to reload your interface with accounts[0]! })

Thanks

cds-amal commented 4 years ago

Hi @eloudsa, I wish I had a better answer for you. At the moment, @drizzle/store does not incorporate subscription on window.ethereum, but it should going forward. @adrianmcli @DiscRiskandBisque thoughts?

@eloudsa. please give me some time to review the scope of this work and I will comment with updates.