TKUIResultsFetcher

public class TKUIResultsFetcher

Fetches trips for a request

Also takes care of localising the user, if the query involves the user’s current location, and handles being hit multiple times with different requests by only returning results from the last requested query.

  • The progress of a single routing fetch request

    See more

    Declaration

    Swift

    public enum Progress : Equatable
  • Kicks off fetching trips, providing process via an observable stream.

    Note

    If the request is for “now”, the request will get modified by locking in the departure times.

    Note

    If the request uses the current location, the location will also get locked in.

    Declaration

    Swift

    public static func streamTrips(for request: TripRequest, modes: Set<String>? = nil, classifier: TKTripClassifier? = nil, baseURL: URL? = nil) -> Observable<Progress>

    Parameters

    request

    The request for which to fetch trips

    modes

    The modes to enable. If set to nil then it’ll use the modes as set in the user defaults (see TKUserProfileHelper for more)

    classifier

    Optional classifier, see TKTripClassifier for more

    Return Value

    Stream of fetching the results, multiple call backs as different modes are fetched.

  • Create a new replacement location for the user’s fetched current location that can then be saved to the current TripRequest object.

    The recommendation is to check against the user’s favourites and use those if they are nearby, so that the user sees “From home” rather than “From some address near my home”.

    Declaration

    Swift

    public static var replacementHandler: (CLLocation) -> TKNamedCoordinate
  • Replace the set of provided modes with the modes returned by the Single, called before by streamTrips at the very start and information is not cached.

    Declaration

    Swift

    public static var modeReplacementHandler: ((TKRegion, Set<String>, TripRequest) -> Single<Set<String>>)?