Open deniszink opened 8 years ago
I have a similar logic in my study project. I defined a interface in the domain layer(https://github.com/enuoCM/DE-MVP-Clean/blob/master/app/src/main/java/com/xixicm/de/domain/interactor/SentenceFetchScheduler.java), and a use case(https://github.com/enuoCM/DE-MVP-Clean/blob/master/app/src/main/java/com/xixicm/de/domain/interactor/ScheduleFetchTodaysSentenceUC.java) to call it. The alarm implementation of the SentenceFetchScheduler interface is in a separate infrastructure layer(https://github.com/enuoCM/DE-MVP-Clean/blob/master/app/src/main/java/com/xixicm/de/infrastructure/alarm/AlarmSentenceFetchScheduler.java).
Hi, I have a question, if I have to implement something like alarm, that will trigger at specific time and run my use case, setting an alarm is business logic of my app, so it should be located in domain(direct me if I wrong) and it's use case should set up my alarm, so it should has the android classes. At this moment I have domain module like android library, and one use case set up an alarm that starts a broadcast, ideally that broadcast should run the same use case (and set up another alarm). I would like to know a valid approach, how to do that.
Logic:
(implemented) 1. User add cycle transaction and add set alarm. AddCycleOperationUseCase --> write to db (implemented) 2. AddCycleOperationUseCase set the AlarmManager with intent with CycleOperation model (want) triggering broadcast that ideally has injected AddCycleOperationUseCase and it will do same operation again.
P.S. I saw few examples of CA by Uncle Bob and it seems domain module it's something like a wrapper that encapsulates CRUD, it isn't?