Closed Android1500 closed 1 year ago
getMyData()
returns a Flow<Resource<MyModel>>
. Here' MyModel
can be anything, even the List
. There shouldn't be any issue while returning Flow<Resource<List<PostEntity>>>
.
If you're still facing an issue, do post the exact error and I'll have a look.
This is method
fun getPost() : Flow<Resource<List<PostEntity>>>{ return dbBoundResource( fetchFromLocal = { db.getAllPosts()}, shouldMakeNetworkRequest = { localData -> localData == null}, makeNetworkRequest = { apiService.getPosts() }, saveResponseData = { db.insertPost(it) }, onNetworkRequestFailed = { errorMessage, _ -> errorMessage } ).flowOn(Dispatchers.IO) }
It give me error Type mismatch.
Required:
Flow<Resource<List
thanks i fixed it
as you know getMyData() from repo return Flow<Resource> but I want to return Flow<Resource<List>> mean list of PostEntity but is give me error so you have any suggestion for that?