Hi there!
I want to expose my thoughts about this question and also to know what do you think about it.
So I have a MVI presenter that has this intent
fun getNearbyPlacesIntent(): Observable<Unit>
I trigger this intent once in the beginning of the activity and it keeps the view updated even if the user moves his location. Basically, the presenter has a LocationProvider dependency which observes for location changes. When there is one, the presenter fetch the Places accordingly and delivers them to the view.
That's mostly fine. The thing is that the locationProvider (which is a dependency of the Presenter) is tightly coupled to the Activity lifecycle, thus it is really difficult (and error prone) to manage this issues regarding the lifecycle keeping the same presenter.
There are 2 alternatives to this:
1 - I can create a global LocationProvider in the app context. However this way I will loose flexibility regarding turn it off/on, or when multiple Activities use locationProvider.
2 - I can just change the intent from
fun getNearbyPlacesIntent(): Observable<Unit>
to
fun getNearbyPlacesIntent(): Observable<MyLocation>
From these two alternatives I'd prefer the second.
I'd love to hear what are your thoughts about this, I'm sure you've been here as well.
Hi there! I want to expose my thoughts about this question and also to know what do you think about it.
So I have a MVI presenter that has this intent
fun getNearbyPlacesIntent(): Observable<Unit>
I trigger this intent once in the beginning of the activity and it keeps the view updated even if the user moves his location. Basically, the presenter has a LocationProvider dependency which observes for location changes. When there is one, the presenter fetch the Places accordingly and delivers them to the view. That's mostly fine. The thing is that the locationProvider (which is a dependency of the Presenter) is tightly coupled to the Activity lifecycle, thus it is really difficult (and error prone) to manage this issues regarding the lifecycle keeping the same presenter.
There are 2 alternatives to this: 1 - I can create a global LocationProvider in the app context. However this way I will loose flexibility regarding turn it off/on, or when multiple Activities use locationProvider. 2 - I can just change the intent from
fun getNearbyPlacesIntent(): Observable<Unit>
tofun getNearbyPlacesIntent(): Observable<MyLocation>
From these two alternatives I'd prefer the second. I'd love to hear what are your thoughts about this, I'm sure you've been here as well.
Thanks!