Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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