Skip to content

Instantly share code, notes, and snippets.

@YusukeIwaki
Created March 29, 2018 07:11
Show Gist options
  • Save YusukeIwaki/32a5491b4853b6af2b2aa2d4e5c78885 to your computer and use it in GitHub Desktop.
Save YusukeIwaki/32a5491b4853b6af2b2aa2d4e5c78885 to your computer and use it in GitHub Desktop.
import android.arch.lifecycle.LiveData
import android.arch.lifecycle.Transformations
fun <X, Y> LiveData<X>.map(f: (X?) -> Y?): LiveData<Y> {
return Transformations.map(this, f)
}
fun <X, Y> LiveData<X>.switchMap(f: (X?) -> LiveData<Y>): LiveData<Y> {
return Transformations.switchMap(this, f)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment