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

Export Event class #5016

Merged
merged 6 commits into from
Nov 12, 2024
Merged

Export Event class #5016

merged 6 commits into from
Nov 12, 2024

Conversation

zdila
Copy link
Contributor

@zdila zdila commented Nov 7, 2024

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.

Export Event class

  • Link to related issues.

#5015

  • Document any changes to public APIs.
    (already documented)
  • Add an entry to CHANGELOG.md under the ## main section.

@codecov-commenter
Copy link

codecov-commenter commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.22%. Comparing base (8555091) to head (0226e9e).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5016      +/-   ##
==========================================
- Coverage   89.25%   89.22%   -0.03%     
==========================================
  Files         269      269              
  Lines       38286    38287       +1     
  Branches     2347     2339       -8     
==========================================
- Hits        34172    34163       -9     
- Misses       3117     3138      +21     
+ Partials      997      986      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HarelM
Copy link
Collaborator

HarelM commented Nov 7, 2024

Can you give a use case where this is needed?

@zdila
Copy link
Contributor Author

zdila commented Nov 12, 2024

Can you give a use case where this is needed?

We create a geocoding control and would like it to fire some events. I think it whouls do it the Maplibre way (extend Evented and implement IControl (which is just a TS type)).

Class Evened#fire method accepts Event or string. For us string is insufficient as we also want to provide event details.

@HarelM
Copy link
Collaborator

HarelM commented Nov 12, 2024

I actually though about replacing evented class with eventemmiter library in some point,
But I don't mind adding it anyway.

@HarelM HarelM enabled auto-merge (squash) November 12, 2024 14:41
@HarelM HarelM merged commit 3c80ac2 into maplibre:main Nov 12, 2024
15 checks passed
@zdila
Copy link
Contributor Author

zdila commented Nov 13, 2024

Thanks.

eventemitter3 on npm doesn't seem to be actively developed. Maybe browser-native EventTarget. Also nanoevents looks good. In any case I think that extending from even-related class is antipattern. In my case, the MaplibreGeocodingControl control itself extends from GeocodingCotrolBase class where GeocodingCotrolBase is library agnostic and is used also for extending by Leaflet control implementation and so it can't extend from Maplibre Evented. I had to use ugly mixins.

@HarelM
Copy link
Collaborator

HarelM commented Nov 13, 2024

Yeah, I agree...

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