Removing idle state #299
Replies: 2 comments 3 replies
-
Adding some thoughts/questions:
As mentioned the "difficulty" will be that many of these states are not mutually exclusive. While you're paused, you're still navigating. You could be in a tunnel while rerouting. I have no suggestion for an architecture for this, just throwing it in as food for thought :) - But yes, I do not see a clear benefit of the idle state, especially if ferrostar doesn't set it. Completed sounds useful. |
Beta Was this translation helpful? Give feedback.
-
More recently, I have been thinking of FerrostarCore as a sort of state machine - one that manages various state transitions within navigation. Considering that every company has different requirements for what they're building, the nice thing about this is it allows people to do their own thing - transitioning between different state machines or augmenting states from the Ferrostar state machine. For example, we use the "default" state today to handle route previews. Anything before route previews is handled by a separate state machine that emits the proper state for what the person sees on the screen (things like details about search, points of interest, etc). I think the current architecture makes it possible to implement the pause mode @hactar suggested, for example, by combining the navigation state with something from the overall application state to have an overall state of either paused or navigating (assuming that methods to enable/disable location services during a trip). |
Beta Was this translation helpful? Give feedback.
-
Background
When implementing
TripState
, I envisioned it as an enum with 3 variants: idle, navigating, and complete. The first and last variants contain no data but are merely markers that indicate an initial or terminal state.It was originally envisioned that apps would always keep some
TripState
around as a signal of whatFerrostarCore
was doing.Problems
Over time, we've identified a few problems in this approach.
For one, it is confusing since now there are multiple possible ways of representing an "initial" state. Both the idle variant and null/nil are valid representations, depending on your view model/observable/similar state data structures. This is further complicated by the fact that you may not have even had a good reason to initialize FerrostarCore at the point your view is created, so devs would need to hack up a zero-argument constructor that constructs an idle state when
null
would do.It's also ambiguous when state should ever reset to
idle
. This is something you would have to manually do (again, constructing a state value) in your view model at some point.FerrostarCore
will never emit an idle variant by itself, so it's not very clear to users how this is intended to be used. Over time the included defaults, demo view models, and so on that we've shipped with Ferrostar have migrated to prefer nil/null as a signal that no navigation is currently in progress or recently finished (this was a move I wasn't entirely sure of at the time @Archdoog proposed it, but in the past few months I've come to agree with the decision).Proposal: Remove the idle variant, but keep completed
As such, I propose we remove the idle variant. This will necessitate some app changes, but it also seems to me like it clarifies things a bit for discussions like #275. The "non-navigation" modality of the map is active only when the tripState is null/nil.
The completed state still seems useful to me, since many apps have "post-trip" flows. This provides a useful third state between "Ferrostar is completely inactive" and "Ferrostar isn't doing anything, but it did complete a trip." App developers can then decide when it's appropriate to clear that state.
Tangential item for discussion: We're also considering event hooks for things like "trip started" and "trip ended." I haven't had the head space to collect thoughts on that into a coherent doc, but if anyone is so inclined, have at it :)
Beta Was this translation helpful? Give feedback.
All reactions