Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throttleSignalWhileInactive is sending events while the receiver is inactive #33

Closed
serluca opened this issue Jun 13, 2016 · 7 comments
Closed
Labels

Comments

@serluca
Copy link

serluca commented Jun 13, 2016

I'm observing that signals are not properly throttled, I can observe that it fires signals while the active property is false.
It also fires an event as soon as the active property become false.

Am I doing something wrong?

@esttorhe
Copy link
Member

Hi @serluca thanks for pointing this out.

Currently throttle was an approach mimicking the implementation of ReactiveViewModel.
Right now we have more operators on RxSwift that could be used to accomplish this in a better way.

Haven't checked recently but chances are you are correct and the current behavior is not working 💯 of the time as one would have expected it to.

I'll give it a try again with the new operators and will fix it as soon as I can.

@esttorhe esttorhe added the bug label Jun 14, 2016
@serluca
Copy link
Author

serluca commented Jul 12, 2016

Hi @esttorhe

Not sure if can help but let me tell you my experience with RxViewModel (I'm having this on the latest release 3.1.3 and also on the pre-release 3.1.4).

As I said, I noticed that throttleSignalWhileInactive it fires signals while the active property is false. I also noticed that it doesn't fire as soon as my subject it sends the next signal, but there is a bit of delay. I looked into RxViewModel and I found that there is a property let throttleTime: NSTimeInterval = 2.

So it seems that the signal is not throttled waiting the didBecomeActive, but it fires when the throttleTime expires.

@esttorhe
Copy link
Member

Yes thanks @serluca; I finally got some time off this week and I'll try to replace the throttle mechanism to use the pre defined throttle operator instead of rolling my own like I did when I first created this.

I'll try to release v. 3.1.5 by EOW.

If you would like to give it a try and know a version that uses the predefined operator and submit a PR that would be amazeballs 😬
But if not i'll be releasing this new version soon

@RamwiseMatt
Copy link

Is there any status update on this? throttleSignalWhileInactive would be very helpful, provided it works!

@esttorhe
Copy link
Member

OK; I've finally had some time to seat down and check the issue.

I change a little bit the behavior but everything is working as expected.

@serluca you are correct in your analysis that it will throttle based on the timer set.
This is the default behavior of the throttle operator (throttle only does it for a period of time).

The convenience operator throttleWhileInactive basically means that it will throttle the signal whenever the viewmodel is inactive (with a predefined period of time of 2 seconds)

TL;DR;: That part is working as designed.

On the other hand it shouldn't fire a signal when the property is set to false; I tested it locally and on a couple of machines and couldn't reproduce this behavior, could you provide a sample code that actually demonstrates that it's firing an event when set to false?

@serluca
Copy link
Author

serluca commented Aug 22, 2016

Hi @esttorhe

I'm currently in vacation, I'll try to send one as soon as possible, but based on what you have just described maybe is not an issue. I'll get back to you.

Thanks

@esttorhe
Copy link
Member

I'm going to be closing this issue.

Please feel free to open another one if you still think this is a bug

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

No branches or pull requests

3 participants