https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
a

aksh1618

01/18/2019, 5:11 PM
Hey, I'm trying to adopt clean architecture for an app for a college fest. There are three entities I need to handle, which I'm currently storing in Room db. I want to use Repository pattern, so I'm creating the Repository interface to be implemented by the three. 1. Should I mark
getAll
as
suspend
? As currently it isn't required due to Room (Using LiveData<List>), but may be required if/when some other source of data is added? 2. Should the code to fetch data from server and populate Room's db be written in the Repository?
j

jalexdev

01/18/2019, 11:24 PM
1. I'd say that
LiveData
and coroutines (which I think is what you mean by
suspend
) are different solutions to the same general problem which is to allow consumption of data in a non thread blocking manner and specifically in the Android world avoid blocking your main thread. So you would want to choose one and shouldn't need both. 2. I'd agree that Repository implementation is a good place to encapsulate any logic that pertains to how the data is sourced and/or maintained.
👍 1
👏 1