add a flag to see if mapboxgl draw is initialized #1245
Closed
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.
Related Ticket: {link related ticket here}
Description of Changes
This PR introduces
drawToolInitialized
state touseAois
hook so it can be used to safely call the methods of mapboxdraw.Notes & Questions About Changes
While refactoring, we realized that just checking if map instance has mapboxgldraw instance is not enough - this still doesn't guarantee if the store of mapboxgl.draw was initiated (which is initiated after being added to map) or not, and most of methods will throw errors if the store is not initiated.
I was wondering if there is anything that we can reliably say the mapboxgl draw store is initialized, and found the event that can be a better indicator of the store initialization - which is
draw.actionable
: https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/API.md#drawactionableThis PR is not complete ex.
draw.actionable
is actually not about the initialization, it is more about what actions are currently available - sosetDrawToolInitialized
is getting called more than needed now. But just opening it to share the idea with the team membersValidation / Testing
This PR should not introduce any visible change to users (it should decrease the occadence that developers face on local environment)
Also I won't work on this PR for the rest of the sprint, but just wanted to push the experiment since we just put a lot of workaround for this problem.
I don't expect the review at this point, but just tagging the people who worked on AOI related problems recently @dzole0311 @AliceR @sandrahoang686