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

Move addSourceType to global object #3420

Merged
merged 5 commits into from
Nov 28, 2023
Merged

Conversation

HarelM
Copy link
Collaborator

@HarelM HarelM commented Nov 28, 2023

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.

@HarelM HarelM requested a review from neodescis November 28, 2023 21:00
@@ -231,6 +231,15 @@ class MapLibreGL {
static removeProtocol(customProtocol: string) {
delete config.REGISTERED_PROTOCOLS[customProtocol];
}

Copy link
Collaborator

@neodescis neodescis Nov 28, 2023

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.

Copy link
Collaborator Author

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?

Copy link
Collaborator

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...

Copy link
Collaborator Author

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.

Copy link
Collaborator

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-commenter
Copy link

codecov-commenter commented Nov 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (dec7af2) 75.57% compared to head (473a578) 75.60%.

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.
📢 Have feedback on the report? Share it here.

@HarelM HarelM mentioned this pull request Nov 28, 2023
7 tasks
@HarelM HarelM merged commit 17f2311 into main Nov 28, 2023
14 checks passed
@HarelM HarelM deleted the move-add-custom-source-to-global branch November 28, 2023 22:58
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.

3 participants