Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun test() = flow {
- val result: MutableList<DataItem> = ArrayList()
- emit(Resource.Loading(data = null))
- result.clear()
- colorDao.getDatesFlow().collect {
- it.forEach {
- result.add(
- DataItem(
- it,
- colorDao.getColorsByDate(it)
- )
- )
- }
- try {
- emit(Resource.Success(data = result))
- result.clear()
- } catch (exception: Exception) {
- emit(Resource.Error(data = null, message = exception.message ?: "Error Occurred!"))
- }
- }
- }.asLiveData()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement