Adam Kirk
04/03/2019, 12:50 AMclass AssetRepositoryImpl(private val assetDao: AssetDao,
private val assetAPIDataSource: AssetAPIDataSource,
userAPIDataSource: UserAPIDataSource,
userDao: UserDao
) : AssetRepository {
private lateinit var currentUser: User
init {
//Check the database first
userDao.getCurrentUserLiveData().observeOnce {
println("ObserverOnce In AssetRepo Impl ${it.token}")
currentUser = it
}
//When there is an update then update here
userAPIDataSource.downloadedCurrentUser.observeForever {
currentUser = createUser(it)
}
assetAPIDataSource.downloadedCurrentAssets.observeForever { newCurrentAssets ->
persistFetchedCurrentAssets(newCurrentAssets)
}
}
I should note that it works. 🙂 but just because something works doesn’t mean its right and yes I am aware that there is lots missing for proper understanding. hopefully most will be able to understand what I am trying to do. In essence I need a way to access the user inside the asset repo.rkeazor
04/03/2019, 1:40 AMAdam Kirk
04/03/2019, 1:49 AM