A replacement for the mediator LiveData for triggering LiveData transformations.
Usage
Sample code:
val isTriggered: LiveData<Boolean> = Transformations.switchMap(
DoubleTrigger(
myTriggerA, // will be triggered when response A arrives from the API
myTriggerB // will be triggered when response B arrives from the API
)
) {
// When we'll have the data from both of the calls, we can continue:
if (it.first != null && it.second != null) {
doSomething(it.first, it.second)
} else {
AbsentLiveData.create()
}
}
This assumes the AbsentLiveData class to exist, to be used when neither A or B yields results.