2

I want to find out is there something similar to switchmap in kotlin and android (LiveData maybe).

I need to change my request immediately after events that can happen very often and which determine what to request from the server, respectively, I only need the last request

Roab
  • 393
  • 3
  • 7

1 Answers1

1

In Kotlin you can use the Transformations library as follows

val someLiveData: LiveData<Type> = ...

val someOtherValue = Transformations.switchMap(someLiveData) { changedValue: Type ->
    //Assign someOtherValue using changedValue, the value coming from someLiveData.
}
JJ Jacobs
  • 123
  • 1
  • 8