-
Couldn't load subscription status.
- Fork 1.9k
Description
I use invalidateLater() to implement custom 'polling', though there are times I want to 'bypass' the time-based invalidation (and force an invalidation sooner). Crafting a wrapper to allow that is mostly straight-forward, but in such cases I also want to clear the currently-in-flight timed invalidation (and typically reset/recreate with a fresh call to invalidateLater()).
invalidateLater() could return a zero-arg function that cancels the task (and session's registered onEnded callback, if any). Given that it currently returns invisible(NULL) and already has references to both needed clearing functions, I believe this would be:
- backwards-compatible, and
- consistent with other return-value-is-a-canceller APIs (including those used by
invalidateLater()itself), and - a fairly tiny code change, replacing:
Line 1884 in 50a140c
invisible()
with:invisible(function() { timerHandle() # clear the scheduled task clear_on_ended_callback() # clear the session's onEnded callback (if any) })
I'm happy to generate that small PR along with tests if this is given the thumbs-up (but will save that effort if there is disapproval).