Closed vekexasia closed 9 years ago
Not sure why by if I change these lines from
publishSubject
.compose(RxLifecycle.bindUntilFragmentEvent(lifecycle(), FragmentEvent.PAUSE))
.observeOn(AndroidSchedulers.mainThread())
to
publishSubject
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycle.bindUntilFragmentEvent(lifecycle(), FragmentEvent.PAUSE))
Everything works just fine....
This is a known problem - OperatorSubscribeUntil
has a chance of leaking events based on where in the chain it's located. For more discussion, see https://github.com/ReactiveX/RxAndroid/pull/168
This should be solved by https://github.com/trello/RxLifecycle/pull/14. I'll work on getting a release out soon since I'd like to see how people react to the new behavior.
I'll leave this open until the next version is released so you can try it out and confirm it's been fixed.
ok thanks :)
I've pushed 0.2.0 to maven central - it should show up in a few hours. Let me know if that fixes the problem.
Hey @dlew I'll let you know tomorrow,
I read the changelog. Did I read wrong or I might expect receiving "onCompleted" after the target FragmentEvent has been triggered?
You will receive onCompleted. It's a change but it's necessary; there's no other way to solve this bug.
The alternative would be a complete rework of the system such that you subscribe in a special manner... which seems much less palatable. Most of the time getting onCompleted is not a big deal.
Hello there,
I started using the library after migrating from the old AppObservable. I experienced some weird crash (very sporadic) due to code being executed after the fragment view was destroyed. Then i tried to tie my tasks to PAUSE events and most of them went away but once in a while i experienced the same behavior.
After some digging and debugging my code i started to realize it is something related with this or the core library (not sure which one yet).
I discovered that sometimes you get the immediately subsequent event after the desired "STOP" FragmentEvent. Ex: If i want to receive events till onPause is called, sometimes i get an event immediately after onPause was sucessfully completed.
For this reason please consider this very basic fragment code
It should look pretty straightforward. I'm trying to publish an integer through the publishSubject every 10ms ( bug appears also with 50ms or 100ms but is more sporadic ).
The generated output (depending how much time you let the fragment running before hitting the back button) should look similar to the following. (Note it does not always happen - as I said with 10ms you've more chances to get see it)
Besides the headaches that this caused to me, it may be a "severe" bug if you bind to DESTROY_VIEW and, as I happened to see, sometimes an event goes through to the subscriber after onDestroyView gets called -> you'll likely to get a nullpointerexception (especially if you use Butterknife.unbind())
Before you ask these are my dependencies.