Skip to content

Instantly share code, notes, and snippets.

View mohodroid's full-sized avatar
🎯
Focusing

Mohsen Mirtalebii mohodroid

🎯
Focusing
View GitHub Profile
/* Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
public class LiveDataTestUtil {
public static <T> T getOrAwaitValue(final LiveData<T> liveData) throws InterruptedException {
final Object[] data = new Object[1];
final CountDownLatch latch = new CountDownLatch(1);
Observer<T> observer = new Observer<T>() {
@Override
public void onChanged(@Nullable T o) {
data[0] = o;