Thread
#android-architecture
    j

    Joost Klitsie

    1 year ago
    hi all! I am making some home-made application where I use a data flow like: Repository <-> UseCase <-> ViewModel <-> View So basically UseCase with MVVM I can find some basic introductions about the usecase pattern, but does anyone have some in-depth article/repo example? I am looking for information about things like this: • Things like observing data (should I first fetch data and after that observe on it, within the useCase) • when to fire a use case and for specific things (like would you fire a usecase to validate input while typing, or only while submitting?) • Should I observe fields from a usecase, or only the output from the execution? • What are the rules where to put specific logic, in the view model or usecase (or both)?
    Javier

    Javier

    1 year ago
    UseCases generally should be used in ViewModels (or presenters), and views observe UseCases maybe is not returning a
    Flow
    (or whatever API you are using), for example, if your app only gets data from network, you don't need to pass a
    Flow
    from datasources -> repositories -> use cases, you only need a
    suspend fun
    and the ViewModel can emit the state with
    Flow
    or
    LiveData