C
C#2y ago
Alex Frost

❔ Delayed call to a function

I am writing search in Blazor and the search needs to happen without enter or tab press. What I want is for a timer to be incremented on each key-press and once typing stops and delay is achieved, it should call the function. Few of the methods I tried call the search many times.
3 Replies
phaseshift
phaseshift2y ago
use a timer, update the interval properly. Or stop the previous timer and make a new one
JakenVeina
JakenVeina2y ago
if you wanna go REALLY crazy
IObservable<string> textBoxValueChanged = ...;

var subscription = textBoxValueChanged
.Debounce(TimeSpan.FromSeconds(1))
.Subscribe(textBoxValue => PerformSearch(textBoxValue));
IObservable<string> textBoxValueChanged = ...;

var subscription = textBoxValueChanged
.Debounce(TimeSpan.FromSeconds(1))
.Subscribe(textBoxValue => PerformSearch(textBoxValue));
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?