What is right place to start a WorkManager in MVVM architecture Android?
Asked Answered
C

2

9

I have a workmanager that every five hours picks up a word from the roomdb and Notification it

I do not know where is the righ place to put the work manager in the MVVM architecture. Should I use in ViewModel or Repository?

Carberry answered 28/6, 2022 at 10:16 Comment(0)
P
3

For the workmanager you only have worker classes, so you need to create a new package named workers or workmanager and place your workers in that package.

Promulgate answered 28/6, 2022 at 10:23 Comment(3)
in Worker to get data and notification it , Do I have to request to the repository directly or use ViewModel ?Carberry
you can't use viewmodel in worker, you need to add your repository to the worker and use it.Promulgate
@MoCoding I think the question is where we should start worker class, directly inside of a viewmodel or inside of a repositoryBridgettebridgewater
C
1

I think under datastore package or di package or make one work manager package and finally, work manager class can be used in ApplicationModule under di package,

Congregation answered 28/6, 2022 at 10:22 Comment(2)
in Worker to get data and notification it , Do I have to request to the repository directly or use ViewModel ?Carberry
By using ViewModel, we can request access for work manager.Congregation

© 2022 - 2024 — McMap. All rights reserved.