https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
m

Mohamed Ibrahim

06/19/2019, 9:58 AM
I have a case where I'm using
BehaviorRelays
with viewModel, the problem is in case of the device rotation,
ViewModel
subscribe again which cause duplicate subscription with each rotation. I know I could save a subscription with
Disposable
and dispose it if it exists, then subscribe .. but is there any other cleaner solution.
s

Sam

06/19/2019, 10:49 AM
u

ursus

06/19/2019, 6:17 PM
you should not subscribe again on rotation, thats the whole point of viewmodel retaining
✔️ 1
m

Mohamed Ibrahim

06/25/2019, 4:23 PM
@ursus yes but how you observe ui, the whole ui is recreate with the life cycle, you must to bind subscriptions again.
u

ursus

06/25/2019, 4:24 PM
sideffect to behavior relays,and expose them to the ui
m

Mohamed Ibrahim

06/25/2019, 4:27 PM
that's when you need to update UI, but how to Observe user interactions, like clicks, updating texts
u

ursus

06/25/2019, 4:41 PM
oh yea sorry, I use regular functions like viewModel.userClick()
4 Views