hadiyarajesh / flower

Flower simplifies networking and database caching on Android/Multiplatform.
Apache License 2.0
288 stars 27 forks source link

Need help for return list #37

Closed Android1500 closed 1 year ago

Android1500 commented 1 year ago

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?

hadiyarajesh commented 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.

Android1500 commented 1 year ago

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>> Found: Flow<Resource>

Android1500 commented 1 year ago

thanks i fixed it