Remove unnecessary Navigator status pulling from updateRouteLeg method#3269
Remove unnecessary Navigator status pulling from updateRouteLeg method#3269S2Ler wants to merge 2 commits into
Conversation
After navigator.changeRouteLeg, a new navigator status will be generated with origin equal to changeRouteLeg where we update indexes anyway.
| } | ||
| private func updateRouteLeg(to legIndex: Int) { | ||
| precondition(legIndex >= 0, "Leg index can't be negative") | ||
| navigator.changeRouteLeg(forRoute: 0, leg: UInt32(legIndex)) |
There was a problem hiding this comment.
Even if the navigator responds to the leg change and updates the navigator status very quickly and synchronously, RouteController responds to the status update asynchronously. This could violate the developer’s expectation, because updateRouteLeg(to:) is called from the public Router.advanceLegIndex() method, which looks like a synchronous method to the developer. The developer may be following up with operations that depend on the status being updated, for example to update UI to reflect the new leg.
To set the right expectations, I think Router.advanceLegIndex() will need to be renamed Router.advanceLegIndex(completionHandler:). Alternatively, we could leave the redundant getStatus() in place if MapboxNavigationNative considers it harmless.
|
#3342 removes the synchronous |
After navigator.changeRouteLeg, a new navigator status will be generated with origin equal to changeRouteLeg where we update indexes anyway.
Related comment: #3265 (comment)