SubscriptionCallback

open class SubscriptionCallback<T> : ParseSubscription where T : ParseObject

A default implementation of the ParseSubscription protocol using closures for callbacks.

  • Declaration

    Swift

    public typealias Object = T
  • Creates a new subscription that can be used to handle updates.

    Declaration

    Swift

    public init(query: Query<T>)
  • Register a callback for when an event occurs.

    Declaration

    Swift

    @discardableResult
    open func handleEvent(_ handler: @escaping (Query<T>,
                                                Event<T>) -> Void) -> SubscriptionCallback

    Parameters

    handler

    The callback to register.

    Return Value

    The same subscription, for easy chaining.

  • Register a callback for when a client succesfully subscribes to a query.

    Declaration

    Swift

    @discardableResult
    open func handleSubscribe(_ handler: @escaping (Query<T>,
                                                    Bool) -> Void) -> SubscriptionCallback

    Parameters

    handler

    The callback to register.

    Return Value

    The same subscription, for easy chaining.

  • Register a callback for when a query has been unsubscribed.

    Declaration

    Swift

    @discardableResult
    open func handleUnsubscribe(_ handler: @escaping (Query<T>) -> Void) -> SubscriptionCallback

    Parameters

    handler

    The callback to register.

    Return Value

    The same subscription, for easy chaining.

  • Declaration

    Swift

    open func didReceive(_ eventData: Data) throws
  • Declaration

    Swift

    open func didSubscribe(_ new: Bool)
  • Declaration

    Swift

    open func didUnsubscribe()
  • Register a callback for when an event occurs of a specific type Example: subscription.handle(Event.Created) { query, object in // Called whenever an object is creaated }

    Declaration

    Swift

    @discardableResult
    public func handle(_ eventType: @escaping (T) -> Event<T>,
                       _ handler: @escaping (Query<T>, T) -> Void) -> SubscriptionCallback

    Parameters

    eventType

    The event type to handle. You should pass one of the enum cases in Event.

    handler

    The callback to register.

    Return Value

    The same subscription, for easy chaining.