Skip to content

Instantly share code, notes, and snippets.

View prfarlow1's full-sized avatar

Peter Farlow prfarlow1

View GitHub Profile
@prfarlow1
prfarlow1 / Coroutines LiveData organization
Last active May 14, 2020 03:10
I'm having trouble understanding best practices around the liveData builder function. Is one of these example incorrect? If not, what guidelines would help me pick whether to build the LiveData in my ViewModel layer vs my repository layer?
class MyViewModelOne(private val dataRepositoryOne: DataRepositoryOne) : ViewModel() {
fun fetchDataButtonClicked() = liveData {
emit(dataRepositoryOne.fetchData())
}
}
class DataRepositoryOne(private val webInterface: MyWebInterface) {
suspend fun fetchData() = webInterface.fetchWebData()
}
package intrepid.io.fable;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import intrepid.io.fable.rest.CreateStoryRequest;