Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only emit state change events after initialization #117

Merged
merged 4 commits into from
Dec 7, 2020

Conversation

rekmarks
Copy link
Member

@rekmarks rekmarks commented Dec 4, 2020

It was reported in #110 that chainChanged (and by extension, networkChanged) is sometimes emitted for the first time after page load, causing a reload loop for those handling chain changes by reloading the page. When the chainId is set on initialization, the chain has not changed, and chainChanged should not be emitted. The same can be said for accountsChanged, which currently would emit under the same circumstances.

This PR ensures that chainChanged, networkChanged, and accountsChanged are only emitted after the provider has been initialized.

Fixes #110

@rekmarks rekmarks requested a review from a team as a code owner December 4, 2020 03:55
@rekmarks rekmarks requested a review from danjm December 4, 2020 03:55
@brad-decker
Copy link

LGTM, after merge conflicts @rekmarks

@rekmarks rekmarks requested review from brad-decker and removed request for danjm December 7, 2020 21:20
@rekmarks rekmarks merged commit 965001e into main Dec 7, 2020
@rekmarks rekmarks deleted the only-emit-events-after-initialization branch December 7, 2020 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chainChanged emits on page load
2 participants