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
The Debounce extension method is not correctly updating the Action in the ConcurrentDictionary. This is causing the debounce extension to trigger the oldest version of the action in the 'chain' instead of the latest.
Steps to Reproduce
I've made a small test in order to confirm the bug:
[TestClass]publicclassDebounceTests{privatestaticDispatcherQueueTimer_debounceTimer;privatestring_searchedTerm;privatedouble_typingInterval=200;[ClassInitialize]publicstaticasyncTaskInitializeAsync(TestContextcontext){awaitThreadHelper.ExecuteOnUIThread(()=>{_debounceTimer=DispatcherQueue.GetForCurrentThread().CreateTimer();});}privateTaskDelayAsync(doublemilliSeconds)=>Task.Delay(TimeSpan.FromMilliseconds(milliSeconds));[TestMethod]publicasyncTaskShouldTriggerTheLatestAction(){TriggerDebounce("T");awaitDelayAsync(_typingInterval);TriggerDebounce("Te");awaitDelayAsync(_typingInterval);TriggerDebounce("Tes");awaitDelayAsync(_typingInterval);TriggerDebounce("Test");awaitDelayAsync(800);// Waits debounce time_searchedTerm.Should().Be("Test");// <- Is failing with "T"}privatevoidTriggerDebounce(stringvalue){_debounceTimer.Debounce(()=>{_searchedTerm=value;},TimeSpan.FromSeconds(0.6));}}
Expected behavior
As i understand, the debounce should trigger the latest Action passed to the method.
Describe the bug
The Debounce extension method is not correctly updating the Action in the ConcurrentDictionary. This is causing the debounce extension to trigger the oldest version of the action in the 'chain' instead of the latest.
Steps to Reproduce
I've made a small test in order to confirm the bug:
Expected behavior
As i understand, the debounce should trigger the latest Action passed to the method.
Screenshots
Test failing:
Environment
NuGet Package(s): v7.1.0
Package Version(s): v7.1.0
Windows 10 Build Number:
App min and target version: