Android Drop-In UI: NavigationState callbacks should allow actions to be dispatched
Android API: 33 Mapbox Navigation SDK version: 2.8.0-rc.3
Steps to trigger behavior
- Create a
NavigationViewListener - Add an
onArrivalmethod that tries to callnavigationView.api.startFreeDrive() - Will be discarded by the
Storesince it is still processing the action.
Expected behavior
I would have expected to be able to start requesting new actions in state callbacks like onArrival.
Especially since there is no functionality to just queue dispatched actions on the Store.
My use case in the app I'm developing, is to reset the view to Free Drive after arriving at a destination.
Thank you :)
Hi @saibotk. Thanks for using Drop-In UI and filing this issue.
You are correct. TheStore ignores any actions dispatched during the processing of the current action.
This was intentionally designed this way to avoid hard-to-resolve issues like:
- state corruption caused by action dispatch with an incomplete/transient state (new action dispatched before all reducers finish updating the state when processing current action)
- infinite loops caused by never-ending processing of two actions in a flip-flop behaviour (action A causes reducer R1 to dispatch action B, which causes reducer R2 to dispatch action A, leading to chain
A -> R1 -> B -> R2 -> A -> R1)
We want to expand NavigationView capabilities to help you implement the desired experience. However, to do this, we need to understand your use case fully.
Are you trying to:
- hide Active Guidance views on Arrival (Maneuver View, Route Line, Action Buttons, Trip Progress)?
- disable/hide Info Panel Arrival header?
- disable the Arrival state by immediately entering FreeDrive mode on arrival?
- none of the above
Hi @saibotk. Thanks for using Drop-In UI and filing this issue. You are correct. The
Storeignores any actions dispatched during the processing of the current action.This was intentionally designed this way to avoid hard-to-resolve issues like:
- state corruption caused by action dispatch with an incomplete/transient state (new action dispatched before all reducers finish updating the state when processing current action)
- infinite loops caused by never-ending processing of two actions in a flip-flop behaviour (action A causes reducer R1 to dispatch action B, which causes reducer R2 to dispatch action A, leading to chain
A -> R1 -> B -> R2 -> A -> R1)We want to expand NavigationView capabilities to help you implement the desired experience. However, to do this, we need to understand your use case fully.
Are you trying to:
- hide Active Guidance views on Arrival (Maneuver View, Route Line, Action Buttons, Trip Progress)?
- disable/hide Info Panel Arrival header?
- disable the Arrival state by immediately entering FreeDrive mode on arrival?
- none of the above
@saibotk I would appreciate if you help us understand your use case by answering the question when you get a chance.
Hello,
sorry had a pretty busy week, but nice to see you care about the issue that much. I appreciate it!
So in our use case, I'm actually trying to do 3. where i want to use the callback to switch the state back to freedrive. I cannot really control the state in any other way on arrival and need to use the callback.
Ideally the action would already be processed and the state change callback would be called afterwards.
Thank you for clarifying @saibotk
I am curious to understand your use case as it is a bit unusual as usually navigation apps should have an arrival state. onArrival is triggered when the driver is some distance away from the destination. Based on this if you skip arrival state and directly go back to free drive, there is a possibility that the user can go off route even before they reach the destination.
Can you explain a bit more about your use case?
Sure,
We are using the navigation purely to direct a driver to a location and he then has tasks on site. Afterwards we need them to be navigated to another site.
This task is also displayed on the map thus we want to use the free drive mode and cannot really use a screen on arrival.
It is also a nice thing to be able to react to the arrival instantly instead of having to use artificial delays, to wait until the action is processed.
This seems to be fixed now, at least it is working in my use case