Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

Throttle not working as expected #15

Open
bokmadsen opened this issue May 8, 2012 · 5 comments
Open

Throttle not working as expected #15

bokmadsen opened this issue May 8, 2012 · 5 comments

Comments

@bokmadsen
Copy link

Throttle (in RX anyway) is supposed to only return the last value, if no new value is arriving within the timespan. If a new value arrives, the timer is reset and the value is saved.
The way Throttle works now is that the first value is returned immediately (should not happen) and the timer is not reset on each arrival of a new value, ie. the value is returned when the timespan has been reached regardless of "silence" in the timespan

@atsushieno
Copy link
Owner

Hi, sorry for the belated reply!

I think the problem you are seeing is not exactly as what you described. For example, check out this test case:
https://github.com/atsushieno/mono-reactive/blob/master/System.Reactive.Tests/System.Reactive.Linq/ObservableTest.cs#L929

This Throttle() unit test tests a call to Throttle() that takes a joint observable of Range() and Return() in each 50 milliseconds. The first 3 items in Range() are immediately evaluated, so the first item from Throttle() is 3, as the test code expects. And it does not fail.

Could you give me an example repro case so that I can investigate and pin point the actual issue?

@bokmadsen
Copy link
Author

Hi

Thanks for getting back to me.
I've pasted my code here http://pastebin.com/LNhdF7zN. I can't quite figure out if the test will hit the problem I have. Throttle is supposed to wait for the input to settle for the amount of time, before returning the last item.
I want the service to be called when the user have stopped typing for the amount of time, instead of calling it every time. The code is more or less from the demo on the official RX site

I think there is an issue with TakeUntil also - its supposed to only return the last lookup in line 61, but it returns all lookups. I've created a random timeout, to visualize this. This is because I only want the result of the last call to the service

@atsushieno
Copy link
Owner

umm, thanks but I don't have working mac so I can't test your code. I'll try to extract non-MT-dependent repro, but I don't learn Apple API I'm not sure if this will work for me. Anyways let's see what happens...

@atsushieno
Copy link
Owner

I'm on the way to make it platform independent and eliminating random (which is going to prevent testing) ... so far I have https://gist.github.com/2693865.

atsushieno pushed a commit that referenced this issue May 18, 2012
Though this somehow causes "regressive" failure in Throttle() test. I believe
this is due to some other reason.
@atsushieno
Copy link
Owner

I made some fixes so that Throttle() itself should work as expected.

I'm still having some hard time to get identical results from .NET, but it's partly because FromAsyncPattern() involves different thread which makes HistoricalScheduler (which I use for testing without consuming actual time) somewhat useless. Those fixes might be enough for you to get things working.

For TakeUntil(), I need the actual input, not just the code fragment, to reproduce the issue you are seeing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants