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

🎉 add grapherLoaded event #3087

Merged
merged 1 commit into from
Jan 11, 2024
Merged

🎉 add grapherLoaded event #3087

merged 1 commit into from
Jan 11, 2024

Conversation

ikesau
Copy link
Member

@ikesau ikesau commented Jan 10, 2024

Adds a reaction to each Grapher so that when isReady is set to true, a "grapherLoaded" event is emitted. This enables us to do things once we know the Graphers on the page have fully loaded.

This isn't working correctly for datapages, however, because for some reason data page Graphers are mounting 3 times (so three separate events are getting emitted)

Here's a demo of me creating an event listener for the event, which I attach to the document immediately after refreshing the page so that it fires when the Grapher on the page finishes loading. Navigating around the grapher doesn't cause the event to fire again.
https://github.com/owid/owid-grapher/assets/11844404/04adab9e-6b7a-4e8d-aa92-4a97cb2329a2

@ikesau ikesau requested a review from sophiamersmann January 10, 2024 21:20
@ikesau ikesau self-assigned this Jan 10, 2024
Copy link
Member

@sophiamersmann sophiamersmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Very useful addition 🙌🏻

@ikesau ikesau merged commit cba5bef into master Jan 11, 2024
22 checks passed
@ikesau ikesau deleted the grapher-loaded-event branch January 11, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants