samedi 3 avril 2021

LiveData Transformations with Flow

Has I read more about Flow I'm starting to think that you can replace MutableLiveData switchMap pattern with something similiar with flow. You can replace LiveData observation with flow by implementing something like this but I'm unable to imagine how to replace the switchMap part. By switchMap pattern I mean this...

val mutableLiveData: MutableLiveData<SomeClass> = MutableLiveData()
val liveData: LiveData<SomeOtherClass> = mutableLiveData
    .switchMap {
       //call to repo
    }

Is there anything equivalent or am I missing out something completely? Or even thinking about flow completely the wrong way.

Aucun commentaire:

Enregistrer un commentaire