You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
This project was such an immense Clean Architecture learning tool for me. I'd like to ask what would be a way of returning LiveData from a use case, for example, returning LiveData<List<Movie>>
from GetMovies use case and displaying it in MoviesFragment?
Thanks.
The text was updated successfully, but these errors were encountered:
I tend to return io.reactivex.Single from "use-case-like things", but I also instead observe the local data store for io.reactivex.Observable directly.
Not sure why you'd want to return LiveData from a usecase.
LiveData is associated with the lifecycle of the activity/fragment and generally used between viewmodel - activity/fragment communication. To observe something in usecase, we could make use of coroutine's channels and flows.
In the viewmodel, we could use Live data builder to wrap the flow into live-data https://proandroiddev.com/kotlin-flow-on-android-quick-guide-76667e872166
UseCases shouldn't even be stateful. 🤔 That's why LiveData.onActive is powerful, although it'd allow you to lose results if you try to emit multiple events rather than just success/error.
Hello,
This project was such an immense Clean Architecture learning tool for me. I'd like to ask what would be a way of returning LiveData from a use case, for example, returning
LiveData<List<Movie>>
from GetMovies use case and displaying it in MoviesFragment?
Thanks.
The text was updated successfully, but these errors were encountered: