dotnet / dotnet/reactive

Could we have Throttle by task?

Open
#1,270 3 comments 0 reactions 0 assignees View on GitHub
[area] Rx
Dominant language
C#
Stars
7.2k
Forks
798
PR merge metrics
No merged PRs in 30d

Description

### Feature request

I don't know if this operator could be fabricated from other function. But I want a function that could be Throttle the input from stream while the current handler wasn't finished, but not throttle by timing

Suppose there is a http post function that listen to UI input change and send that data to server

```C#
ISubject nameTextField;
nameTextField.Throttle(async(newName) => {
await HTTPPost(newName);
return newName;
}).Subscribe((newName) => {
Console.WriteLine("Updated name to : " + newName);
});
```

What I would like it to happen is, this function would act like `Select` but it would buffer data stream to emit only one last output at a time
1 - If the data was sent to this function for the first time, it will trigger the function immediately
2 - If data was sent to this function, but the previous execution still not finished. Then it would kept that data and wait until the previous execution finished then trigger the function again
3 - If yet another data was sent, it would dispose the previous cache and kept the new one in the waiting queue instead

So as the example. If there is any changed from user input, it will send HTTP Post to server immediately. But if there was internet lagging while user was changing that text field multiple time. I don't want HttpPost to be called parallel, but if the previous one finished I would like to Post the latest value that user have changed

Could we have this kind of function or there was a way to do this already?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.