You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a variety of complicated cards to use in a RecyclerView and we would like to use a Feature for each card. The cards observe multiple Observable sources, and need to be disposed of properly when recycled/backgrounded/etc.
Should we be calling .dispose() on a Feature that belongs to a card that is being recycled?
Is there a way to re-use a Feature after it has been .disposed()? We would rather not have to allocate new Features in onBindViewHolder() as the object allocations can lead to GC/jank.
How does the Binder that we use play into this? Do we need to call .dispose() on it as well? Or is that unnecessary if we are calling .dispose() on each bound Feature when it's no longer needed?
Thank you!
The text was updated successfully, but these errors were encountered:
3.: This seems to be the easiest to answer. You can think of Binder as a shortcut for making a .subscribe() call on an Observable. So those subscriptions need to be disposed of. Features are hot observables though, and will continue undisturbed (see: documentation)
1.: Following from the above, yes
2.: If you already called .dispose() then you can't re-use the same instance anymore. In your use case however, instead of directly calling .dispose(), you can have e.g. a .takeUntil() operator in your Feature's Actor to use some signal stream, and push an element into that when you need it to stop. In this case though, it's another question which scope will you store your Feature instance in and when will you actually dispose of it.
We have a variety of complicated cards to use in a RecyclerView and we would like to use a Feature for each card. The cards observe multiple Observable sources, and need to be disposed of properly when recycled/backgrounded/etc.
Should we be calling .dispose() on a Feature that belongs to a card that is being recycled?
Is there a way to re-use a Feature after it has been .disposed()? We would rather not have to allocate new Features in onBindViewHolder() as the object allocations can lead to GC/jank.
How does the Binder that we use play into this? Do we need to call .dispose() on it as well? Or is that unnecessary if we are calling .dispose() on each bound Feature when it's no longer needed?
Thank you!
The text was updated successfully, but these errors were encountered: