//Extensions for Jetpack Lifecycle/it.czerwinski.android.lifecycle.livedata/groupBy

groupBy

[androidJvm]
Content
fun <K, V> LiveData<V>.groupBy(keySelector: (V) -> K): GroupedLiveData<K, V>
More info

Returns a GroupedLiveData providing a set of LiveData, each emitting a different subset of values from this LiveData, based on the result of the given keySelector function.

keySelector will be executed on the main thread.

Example:

val userLiveData: LiveData = ... val userByStatusLiveData: GroupedLiveData<UserStatus, User> = errorLiveData.groupBy { user -> user.status } val activeUserLiveData: LiveData = userByStatusLiveData[UserStatus.ACTIVE]