SimonDanisch / Bonito.jl

Serving JS to the browser
MIT License
204 stars 29 forks source link

throttle StylableSlider #233

Closed bjarthur closed 2 months ago

bjarthur commented 2 months ago

supersedes https://github.com/SimonDanisch/Bonito.jl/pull/229

throttle_function is now refactored such that it can be used by other components as well. PR to WGLMakie forthcoming...

SimonDanisch commented 2 months ago

Moving throttle seems like a good idea... Although I think for a slider we shouldn't throttle, but instead skip updates while things are calculated, without skipping the last. With throttle, I think the slider may end up at a position, that then doesn't get updated correctly? But discard updates while calculating in julia will be a bit hard to implement on the JS side (although more desirable to send less updates). Since it's difficult in JS, we may want to use Makie's async_latest (which should get moved to Observables 😅 ).

bjarthur commented 2 months ago

perhaps i'm misunderstanding the JS code, or your requirements, but i think they match. each time the slider moves, throttle_function is called which first clears any previous updates still pending. then it either immediately applies the update, or schedules it to be called later. so updates are skipped during calculations and the last update is not skipped. no?

SimonDanisch commented 2 months ago

Ah maybe I forgot that the JS throttle implementation supports this requirement. Guess I mixed it up with the Observables throttle implementation.