I have a ViewModel class with 2 livedata observables (eg a
and b
) that are both of a nullable type and
I want to add a new boolean observable (eg c
) that is true whenever both a
and b
are not null, and false otherwise.
I was recommended to use a LiveData Transformation to achieve this but I'm not quite sure how that would work. With a map transformation, I can only ever transform between a single observer, but I can't add multiple sources.
Then that lead me to looking at representing c
as a MediatorLiveData and add a
and b
as sources but then that relies on the fact that they are all of the same type, so I'm not sure if I can use that either.
What's the idiomatic way to accomplish this?