Kursat
Kursat

Reputation: 21

Where should WorkManager be placed within Clean Architecture?

I created a WorkManager that retrieves the current Bitcoin price from an API every 60 minutes and displays it to the user as a notification. However, I am confused about how to integrate WorkManager with Clean Architecture.

I created an infrastructure layer for WorkManager. Do you think this is correct? In your opinion, where should WorkManager be placed in Clean Architecture?

Scheme of Current Architecture

Package Structure

Upvotes: 2

Views: 1525

Answers (2)

René Link
René Link

Reputation: 51333

From an architectural perspective a work manager is similar to a user interaction. If you wouldn't have a work manger, you would probably let the user trigger the "update bitcoin price" use case with an refresh button. You would register an event listener to the refresh button and invoke a controller when the event is emitted. Thus I would let the work manager invoke the controller.

If your application is divided into a frontend client and backend server part. You have two options. Either let the frontend client use a work manager and send requests every X minutes or implement the work manager on the backend server controller side. But then you need a way to publish the results to the client, either through websockets or let the client poll.

Upvotes: 1

Asad Mahmood
Asad Mahmood

Reputation: 636

Its totally depend on your usecase, if its Business-oriented operations also if you follow official docs then its Data layer

enter image description here

Upvotes: 2

Related Questions