Encapsulate responses in coherent public types #391
Labels
backwards incompatible
changes that break backwards compatibility of public API
op-ex
Refactoring, Tech Debt or any other operational excellence work.
Milestone
Currently,
RouteCompletionHandler
andMatchCompletionHandler
accept multiple arguments that separate the routes (or matches) from the waypoints they connect. Because these arrays are passed in as top-level arguments to the completion handlers, adding more detail about the response would break backwards compatibility. For this reason, we’ve taken to copying metadata about the response as a whole – namely, the response UUID and options object from the request – into each route or match.As part of adopting Codable, #382 implements private MapMatchingResponse, MatchResponse, and RouteResponse classes that represent the response as a whole. These classes give us a convenient, central place to put response metadata and neatly parallel MapKit’s
MKDirections.Response
class. We should make these new classes public and pass them to the completion handler directly instead of dissassembling them for public consumption.At the same time, we should unify the response classes into two classes: MapMatchingResponse would decode Map Matching API responses (as MapMatchingResponse and MatchResponse both currently do), while RouteResponse would decode Directions API responses. For the case that MapMatchingResponse is meant to handle, it would be better for MapMatchingResponse to produce Match objects;
calculateRoutes(matching:completionHandler:)
could call a new initializer on RouteResponse that takes a MapMatchingResponse as input.This refactoring is probably going to be necessary once #388 separates Waypoint into three separate types.
/cc @mapbox/navigation-ios
The text was updated successfully, but these errors were encountered: