force close on sample bg work
siavashabdoli opened this issue · comments
I click on button several times then press back and go to first page. then this error occurs:
at com.morihacky.android.rxjava.fragments.ConcurrencyWithSchedulersDemoFragment$2.onCompleted(ConcurrencyWithSchedulersDemoFragment.java:100)
if you unsibscribe the listener why this happen? can fix this issue pls :)
The issue is that every time you click a new subscription gets created and any already existing subscription leaks. The old subscription will still get GCed, but It will also still call the Observer, and that's what's happening here. Since the fragment is gone, we get NPE's.
Check out the PR I made for the simplest fix.
#77 should address this. Thanks @siavashabdoli for noticing this issue and @marukami for a beautiful explanation of the root cause