Classes

The following classes are available globally.

  • The ParseLiveQuery class enables two-way communication to a Parse Live Query Server.

    In most cases, you should not call this class directly as a LiveQuery can be indirectly created from Query using:

    // If "Message" is a "ParseObject"
    let myQuery = Message.query("from" == "parse")
    guard let subscription = myQuery.subscribe else {
        "Error subscribing..."
        return
    }
    subscription.handleSubscribe { subscribedQuery, isNew in
    
        //Handle the subscription however you like.
        if isNew {
            print("Successfully subscribed to new query \(subscribedQuery)")
        } else {
            print("Successfully updated subscription to new query \(subscribedQuery)")
        }
    }
    

    The above creates a ParseLiveQuery using either the liveQueryServerURL (if it has been set) or serverURL when using ParseSwift.initialize. All additional queries will be created in the same way. The times you will want to initialize a new ParseLiveQuery instance are:

    1. If you want to become a ParseLiveQueryDelegate to respond to authentification challenges and/or receive metrics and error messages for a ParseLiveQueryclient.
    2. You have specific LiveQueries that need to subscribe to a server that have a different url than the default.
    3. You want to change the default url for all LiveQuery connections when the app is already running. Initializing new instances will create a new task/connection to the ParseLiveQuery server. When an instance is deinitialized it will automatically close it’s connection gracefully.
    See more

    Declaration

    Swift

    @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
    public final class ParseLiveQuery : NSObject
  • A default implementation of the ParseSubscription protocol. Suitable for ObjectObserved as the subscription can be used as a SwiftUI publisher. Meaning it can serve indepedently as a ViewModel in MVVM.

    See more

    Declaration

    Swift

    @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
    open class Subscription<T> : ParseSubscription, ObservableObject where T : ParseObject
  • A default implementation of the ParseSubscription protocol using closures for callbacks.

    See more

    Declaration

    Swift

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