Ranter
Join devRant
Do all the things like
				++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
				Sign Up
			Pipeless API
 
				From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
				Learn More
			Comments
		- 
				
				No idea how C# works, but here an idea
 
 time_range = TimeSpan.FromMilliseconds(200)
 value = (string)e.Value)?.Trim()
 
 def throttling_action(x):
 {
 quisckSearch = x;
 InvokeAsync(async () => await LoadFirstPage());
 }
 
 @highlight
 searchThrottle.Throttle(time_range)
 .Select(e => (value)
 .DistinctUntilChanged()
 .Subscribe((x) => throttling_action(x));
 
 Refactor first to have everything as separate readably named values first
 It already looks nicer in my opinion
 
 ================
 Then make an attempt to wrap thing thingy too
 
 time_range = TimeSpan.FromMilliseconds(200)
 value = (string)e.Value)?.Trim()
 
 def throttling_action(x):
 {
 quisckSearch = x;
 InvokeAsync(async () => await LoadFirstPage());
 }
 
 def trotthler_on_value_change(throttler)
 return throttler.Select(e => (value)
 .DistinctUntilChanged()
 .Subscribe((x) => throttling_action(x))
 
 def throttler():
 return highlight
 searchThrottle.Throttle(time_range).
 trotthler_on_value_change()
 
 @throttler();
- 
				
				@prodigy214 that's exactly what this code does. I'm just looking for "less" lines ! But thanks !
- 
				
				@dontbeevil In this case now.
 
 It's really a throttle.
 
 BUT there is a debouncer at the level of LoadFirstPage, which will cancel old task and start a new one.
 
 because that can be called while pagination happens or filter is applied or quick search is performed.



Does anyone have a better way to implement throttle on value changes in c# ?
I'm using this right now and I find it a bit "too much lines"
@highlight
searchThrottle.Throttle(TimeSpan.FromMilliseconds(200))
.Select(e => ((string)e.Value)?.Trim())
.DistinctUntilChanged()
.Subscribe((x) =>
{
quisckSearch = x;
InvokeAsync(async () => await LoadFirstPage());
});
question