Reactive

extension Reactive where Base: NSManagedObjectContext
public extension Reactive where Base : TKLocationManager
extension Reactive where Base: TKServer
extension Reactive where Base == TKContactsManager
extension Reactive where Base: MKLocalSearch
extension Reactive where Base == TKServer
extension Reactive where Base == TKUserProfileHelper
extension Reactive where Base: Vehicle
extension Reactive where Base : TKBikePodLocation
extension Reactive where Base : TKCarPodLocation
extension Reactive where Base : TKCarParkLocation
extension Reactive where Base : TKFreeFloatingVehicleLocation
extension Reactive where Base == TKBuzzInfoProvider
extension Reactive where Base: TKBuzzRealTime
extension Reactive where Base : TKRouter

Available where Base: NSManagedObjectContext

Available where Base : TKLocationManager

  • Fetches the user’s current location and fires observable exactly ones, if successful, and then completes.

    The observable can error out, e.g., if permission was not granted to the device’s location services, or if no location could be fetched within the alloted time.

    Declaration

    Swift

    func fetchCurrentLocation(within seconds: TimeInterval) -> Single<CLLocation>

    Parameters

    seconds

    Maximum time to give GPS

    Return Value

    Observable of user’s current location; can error out

  • Continuously observes the user’s current location and fires observable whenever the user moved more than a minimum threshold.

    The observable can error out, e.g., if permission was not granted to the device’s location services.

    Declaration

    Swift

    var currentLocation: Observable<CLLocation> { get }

    Return Value

    Observable of user’s current location; can error out

  • Observes the device’s heading

    The observable does not error out and not terminate by itself.

    Note

    Internally, each subscription creates a new observable, and a new location manager, so you’re encouraged to share a single subscription.

    Declaration

    Swift

    var deviceHeading: Observable<CLHeading> { get }
  • Declaration

    Swift

    func tryAuthorization() -> Single<Bool>

Available where Base: TKServer

  • Declaration

    Swift

    public func requireRegion(_ coordinate: CLLocationCoordinate2D) -> Single<TKRegion>
  • Declaration

    Swift

    public func requireRegion(_ coordinateRegion: MKCoordinateRegion) -> Single<TKRegion>
  • Declaration

    Swift

    public func requireRegions() -> Single<Void>
  • Hit a SkedGo endpoint, using a variety of options

    Declaration

    Swift

    public func hit(
      _ method: TKServer.HTTPMethod,
      path: String,
      parameters: [String: Any] = [:],
      headers: [String: String] = [:],
      region: TKRegion? = nil
      ) -> Single<(Int, [String: Any], Data?)>

    Parameters

    method

    Duh

    path

    The endpoint, e.g., routing.json

    parameters

    The parameters which will either be send in the query (for GET) or as the JSON body (for POST and alike)

    headers

    Additional headers to add to the request

    region

    The region for which to hit a server. In most cases, you want to set this as not every SkedGo server has data for every region.

    Return Value

    An observable with the status code, headers and data from hitting the endpoint, all status and data will be the same as the last call to the repeatHandler.

  • Hit a SkedGo endpoint, using a variety of options

    Declaration

    Swift

    public func stream(
      _ method: TKServer.HTTPMethod,
      path: String,
      parameters: [String: Any] = [:],
      headers: [String: String] = [:],
      region: TKRegion? = nil,
      repeatHandler: ((Int, Data?) -> TKServer.RepeatHandler?)? = nil
      ) -> Observable<(Int, [String: Any], Data?)>

    Parameters

    method

    Duh

    path

    The endpoint, e.g., routing.json

    parameters

    The parameters which will either be send in the query (for GET) or as the JSON body (for POST and alike)

    headers

    Additional headers to add to the request

    region

    The region for which to hit a server. In most cases, you want to set this as not every SkedGo server has data for every region.

    repeatHandler

    Implement and return a non-negative time interval from this handler to fire the Observable again, or nil to stop firing.

    Return Value

    An observable with the status code, headers and data from hitting the endpoint, all status and data will be the same as the last call to the repeatHandler.

Available where Base == TKContactsManager

Available where Base: MKLocalSearch

  • Declaration

    Swift

    public func start() -> Single<[MKMapItem]>

Available where Base == TKServer

  • Sign the user in using a token from CloudKit, returning the user token.

    Note

    The token is only retrieved, but not stored. Most likely you’ll next want to call TKServer.updateUserToken(_:).

    Note

    There’s no need to sign-up first. If this is the sign-in attempt an account with no information but the cloud kit ID will be created.

    Declaration

    Swift

    public func signIn(withCloudKitID cloudKitID: String) -> Single<String>

    Parameters

    cloudKitID

    The record name of the CloudKit’s user record ID.

    Return Value

    The user token. Can fail.

  • Sign the user in using a UUID, which you might sync using whichever means you prefer.

    Note

    The token is only retrieved, but not stored. Most likely you’ll next want to call TKServer.updateUserToken(_:).

    Note

    There’s no need to sign-up first. If this is the sign-in attempt an account with no information but the UUID will be created.

    Declaration

    Swift

    public func signIn(withUUID uuid: String) -> Single<String>

    Parameters

    uuid

    A UUID of your choosing

    Return Value

    The user token. Can fail.

  • Fetches all server-side data for a user, returning it as raw data, which can be turned in a JSON string or file.

    Note

    Only returns data if a userToken was previously set.

    Declaration

    Swift

    public func downloadUserData() -> Single<Data>

    Return Value

    Data, if any was available

  • Deletes all server-side data for a user, and also signs them out by resetting the user token

    Declaration

    Swift

    public func deleteUserDataAndSignOut() -> Single<Void>

Available where Base == TKUserProfileHelper

Available where Base: Vehicle

  • Declaration

    Swift

    public var components: Observable<([[TKAPI.VehicleComponents]], Date)> { get }

Available where Base : TKBikePodLocation

  • Declaration

    Swift

    public var bikePod: Observable<TKAPI.BikePodInfo> { get }

Available where Base : TKCarPodLocation

  • Declaration

    Swift

    public var carPod: Observable<TKAPI.CarPodInfo> { get }

Available where Base : TKCarParkLocation

  • Declaration

    Swift

    public var carPark: Observable<TKAPI.CarParkInfo> { get }

Available where Base : TKFreeFloatingVehicleLocation

  • Declaration

    Swift

    public var vehicle: Observable<TKAPI.SharedVehicleInfo> { get }

Available where Base == TKBuzzInfoProvider

Available where Base: TKBuzzRealTime

  • Stream real-time updates for the trip

    Declaration

    Swift

    public static func streamUpdates(_ trip: Trip, updateInterval: DispatchTimeInterval = .seconds(10), active: Observable<Bool> = .just(true)) -> Observable<Trip>

    Parameters

    trip

    The trip to update

    updateInterval

    The frequency at which the trip should be updated (default is every 10 seconds)

    active

    Optional stream whether updates should keep being performed, e.g., you can create a bunch of these, but only the active one will be updated. It’s expected that these go back and forth between true and false

    Return Value

    Stream of the trip, whenever it gets updated, i.e., if there’s no update the stream won’t fire.

  • Perform one-off real-time update of the provided trip

    No need to call this if trip.wantsRealTimeUpdates == false. It’d just complete immediately.

    Declaration

    Swift

    public static func update(_ trip: Trip) -> Single<(Trip, didUpdate: Bool)>

    Parameters

    trip

    The trip to update

    Return Value

    One-off callback with the update, indicatating if the trip got updated. Note that the Trip object returned in the callback will always be the same object provided to the method, i.e., trips are updated in-place.

  • Perform one-off updates of the visible trips of each trip group

    Declaration

    Swift

    public static func update(tripGroups: [TripGroup]) -> Observable<TKRealTimeUpdateProgress<Void>>

    Parameters

    tripGroups

    Trip groups, where only the visible trip will be updated

    Return Value

    Progress of the update, but it won’t indicate which trips did get updated

Available where Base : TKRouter