-
-
Notifications
You must be signed in to change notification settings - Fork 757
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
Async Actor
#3233
Async Actor
#3233
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #3233 +/- ##
==========================================
+ Coverage 75.46% 75.50% +0.03%
==========================================
Files 241 241
Lines 19273 19230 -43
Branches 4344 4271 -73
==========================================
- Hits 14545 14520 -25
+ Misses 4728 4710 -18 ☔ View full report in Codecov by Sentry. |
Cancellation can be achieved by passing an optional |
That sounds good. In maplibre-contour I ended up returning a {cancel: function, value: promise} but I did not like how that turned out because all the code had to handle propagating the extra cancel function. It's much cleaner to pass in a cancelation hook to the arguments and just return a promise. |
I've updated the code to allow cancelation. |
OK, I managed to figure out how to map between the request parameters and the response parameters and also how to properly register the handler with the relevant type safety. |
…er. There are still things to do.
I pushed the main commit for this PR just now. |
So for "Ask plugin owners that exist in the examples to make sure they can use this new code" do you want us to just try running plugins against this build? Or is there a different way of "plugging in" that you think we'll need to switch to? |
The plugins will (hopefully) work as I haven't break anything yet in the add protocol API, but I do want to do a more deep API change (remove as much callbacks as possible from the code), and I need to know how well it will be received by plugin owners. |
OK got it. Maplibre-contour appears to work fine from this branch (
That would be great for maplibre-contour so it doesn't need to maintain its own worker. The custom source API is probably the right way to go right now, it will just take some work to get there because we need to expose some more maplibre internals on the main and worker thread for it to hook into. Or we just incorporate the contour plugin directly in maplibre as a new layer type... |
I thought about making it a new layer, but then you lose the styling flexibility you have now. |
* Fix XSS, intorduce subscribe * Update changelog
@msbarry is your life-of-a-tile document at https://github.com/maplibre/maplibre-gl-js/blob/main/developer-guides/life-of-a-tile.md still up-to-date after this? |
The changes are basically refactoring, meaning the code logic didn't change, so I believe it's still relevant, but I'll check nevertheless. |
There might be some references to "finish" or "done" functions which would now just be "continue method ..." |
I think I only saw the |
* Upgrade jest, fix tests, remove console log messages. * Fix incorrect additions, lint
* Remove more places that use cancelable * Remove more places with canceable
* Remove more places that use cancelable * Remove more places with canceable * callback and promise * Improve sources code when it is related to callback * Use callback failback when needed * Update build size test * Removed callbacks from various places, adding docs, simplifying tests * Improve type * Update src/util/actor.test.ts Co-authored-by: neodescis <[email protected]> * Make load async for all sources --------- Co-authored-by: neodescis <[email protected]>
I'm pushing the merge button! :-) |
The aim of this PR is to remove a lot of the callback hell that currently resides in the code.
It does it by exposing the low communication layer i.e. ajax and actor using the promise API.
Cancellation is done using
AbortController
.In order to run a method in a worker or in the main thread there's a need to register to a specific event.
This will introduce a lot of breaking changes so it will be mandatory to create version 4 after this is merged.
Open tasks:
Create a 3.6 version with optional promisesI don't think it's worth the effort...Create a working example for add custom sourcetoo complicated for an example :-(Needed changes after this PR:
addSourceType
to global object #3420loadImage
should return a promise instead of this - Remove callback fromloadImage
#3422any
- ImproveloadTileJson
types #3423