Update group membership for a group call when it changes.

This commit is contained in:
Cody Henthorne
2020-12-05 20:55:52 -05:00
committed by GitHub
parent 234e4be924
commit 2dcc7d284f
5 changed files with 185 additions and 11 deletions

View File

@@ -129,6 +129,25 @@ public final class LiveDataUtil {
return mediatorLiveData;
}
/**
* Skip the first {@param skip} emissions before emitting everything else.
*/
public static @NonNull <T> LiveData<T> skip(@NonNull LiveData<T> source, int skip) {
return new MediatorLiveData<T>() {
int skipsRemaining = skip;
{
addSource(source, value -> {
if (skipsRemaining <= 0) {
setValue(value);
} else {
skipsRemaining--;
}
});
}
};
}
/**
* After {@param delay} ms after observation, emits a single Object, {@param value}.
*/