You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Converting this question from the Slack into a discussion here, for visibility.
I'm having issues with the use of an ImmediateClock not actually performing work immediately, at least when used with my fairly basic debouncer type.
When using this debouncer with an ImmediateClock, I'd expect it to effectively bypass debouncing anything, bypass the clock.sleep call, and just immediately call perform(). Maybe my intuition on this is wrong?
I've got to pass an actual TestClock to get this to work in tests, which means actually calling clock.advance. In the real app, it also works fine with a ContinuousClock or SuspendingClock.
I've attempted using withMainSerialExecutor with some Task.yield() in case the debouncer's Task was the problem, but that didn't seem to fix anything.
This isn't a blocker, as I have a workaround in just using a TestClock and advancing manually, but it'd be really appreciated if someone could at least understand and explain why ImmediateClock isn't working, well, immediately in this situation! If there's something I can change in how I'm using clocks, or something that's technically incorrect anywhere, I'd love to know of a fix!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Converting this question from the Slack into a discussion here, for visibility.
I'm having issues with the use of an
ImmediateClock
not actually performing work immediately, at least when used with my fairly basic debouncer type.For context, the Debouncer looks like this:
When using this debouncer with an
ImmediateClock
, I'd expect it to effectively bypass debouncing anything, bypass theclock.sleep
call, and just immediately callperform()
. Maybe my intuition on this is wrong?I've got to pass an actual
TestClock
to get this to work in tests, which means actually callingclock.advance
. In the real app, it also works fine with aContinuousClock
orSuspendingClock
.I've attempted using
withMainSerialExecutor
with someTask.yield()
in case the debouncer'sTask
was the problem, but that didn't seem to fix anything.This isn't a blocker, as I have a workaround in just using a
TestClock
and advancing manually, but it'd be really appreciated if someone could at least understand and explain whyImmediateClock
isn't working, well, immediately in this situation! If there's something I can change in how I'm using clocks, or something that's technically incorrect anywhere, I'd love to know of a fix!The full sample code is here: https://github.com/rhysm94/ImmediateDebounceIssue
Beta Was this translation helpful? Give feedback.
All reactions