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

Unsubscribe unexpectedly when used in item of 'RecyclerView' inside 'ViewPager2' after page changed. #430

Closed
tankpow opened this issue Aug 17, 2020 · 1 comment

Comments

@tankpow
Copy link

tankpow commented Aug 17, 2020

Library version: 2.0.0

Repro steps or stacktrace: No stacktrace
I followed offcial tutorial of android develop to build a UI which uses 'ViewPage2' and 'Tablayout':

  1. There are one parent fragment and two children fragment as view pages.
  2. Inside children fragment view page, there is 'RecyclerView'. And there is a button inside item view of 'RecyclerView', and it uses 'AutoDispose2' and 'RxBinding' to subscribe to 'click' event by using children fragment as 'LifeCyclerOwner'.
  3. Inside children fragment view page, there is 'EditText' of which event is also subscribed via 'AutoDispose2' and 'RxBinding' by using children fragment as 'LifeCyclerOwner'.
  4. Before children fragment view page is changed by swiping, event is consumed as expectation. BUT, after children fragment view page is changed, subscritpion of button inside Item view of 'RecyclerView' is unsubscribed, WHILE subscription of 'EditText' outside 'RecyeclerView' but in the same fragment view page with the same 'LifeCyclerOwner' still WORKS!
  5. I tried to debug why this happens by:
    i. Comment out '.to(autoDisposable(AndroidLifecycleScopeProvider.from(m_lifecycleOwner)))' of subscription to button inside item view of 'RecyclerView', the subscrption sustained after fragment view page change, and even is consumed.
    ii. I use the raw event listen pattern without any Rx patten to verify whether 'click' event of button is fired. 'Click' event did fire after fragment view page change.
    iii. I changed 'LifeCyclerOwner' ti parent fragment, and everything works fine.
    iv. I use '@OnLifecycleEvent(Lifecycle.Event.ON_ANY)' to log state change, but only get 4 state: PRE_ON_CREATE, CREATED, STARTED, RESUMED.

My question is, what causes 'AutoDispose2' unsubscribed from the button inside item view of 'RecyclerView' after view page change, while subscrition of 'EditText' in the same children fragment with the same 'LifeCyclerOwner' still works?

@ZacSweers
Copy link
Collaborator

Please post usage questions on stackoverflow with the autodispose tag

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

No branches or pull requests

2 participants