[FluentInputBase] Use Debouncer
instead of PeriodicTimer
for debouncing ValueChanged
handler with ImmediateDelay
.
#2042
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request
📖 Description
This pull request applies the use of the internal
Debouncer
instead of thePeriodicTimer
to debounce values. A live demonstration has also been added to theFluentSearch
page to show howImmediate
can be used, as opposed to theoninput
method.🎫 Issues
#2030: Using the
FluentSearch
input box, but likely any debounce withImmediateDelay
, you can reliably force it to throw an exception, by firing the debounce while thePeriodicTimer
is resetting itself. The exception shows that theCancellationToken
used to reset the timer is set to cancelled, as the timer tries to tick.👩💻 Reviewer Notes
The only code-flow change I've had to make is to push the invocation of the
ValueChanged
handler back to the Dispatcher, withinFluentInputBase.cs
. This is a thread safety precaution, as the use of the Debouncer takes the invocation of UI state changes off-thread.📑 Test Plan
Because this is an implementation swap, any unit tests that cover the debouncing process will still pass, as intended. No further coverage necessary. Systems tests added by way of a working live example.
✅ Checklist
General
Component-specific
⏭ Next Steps
It would be nice to expose the
Debouncer
as public, and promote its use as a simple and effective debouncer, for most situations.