-
-
Notifications
You must be signed in to change notification settings - Fork 735
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
Move addSourceType
to global object
#3420
Conversation
@@ -231,6 +231,15 @@ class MapLibreGL { | |||
static removeProtocol(customProtocol: string) { | |||
delete config.REGISTERED_PROTOCOLS[customProtocol]; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we expose getSourceType here as well? Seems like we should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds right, but what would you use if for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that comes to mind is allowing the source type to be changed at runtime. Allowing retrieval of the type would allow for that, without having to keep track of it outside of MapLibre. Of course, I realize changing some of the things about a source type at runtime would be dangerous...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If anything, remove would be the opposite of add. but I'm not sure how to "remove" code that was added to the worker.
And yes, changing a source is super risky...
I'm not sure either way... I think this API isn't really in use as it is so complicated to get it right...
In general you can mess with the prototype of the source object without the need for this method basically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, understood. I'm also perfectly fine if we leave it as-is for now. Just food for thought.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3420 +/- ##
==========================================
+ Coverage 75.57% 75.60% +0.02%
==========================================
Files 242 242
Lines 19197 19199 +2
Branches 4257 4257
==========================================
+ Hits 14509 14515 +6
+ Misses 4688 4684 -4 ☔ View full report in Codecov by Sentry. |
This moves the
addSourceType
to be a member of the global object.This method is not per map as it add code to all the workers which are shared between all maps in the current website.
This method is similar to addProtocl in a lot of aspects and should be part of the global object.
I'm still not sure if I want to add an example to the examples pages for this method.