SubscriptionCallback

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

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

  • Declaration

    Swift

    public var query: Query<T>
  • Declaration

    Swift

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

    Declaration

    Swift

    public required 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 successfully 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.

  • 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.

QuerySubscribable