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

    public final class ParseLiveQuery : NSObject
  • A default implementation of the QuerySubscribable protocol. Suitable for ObjectObserved as the subscription can be used as a SwiftUI publisher. Meaning it can serve indepedently as a ViewModel in MVVM. Also can be used as a Combine publisher. See Apple’s documentation for more details.

    See more

    Declaration

    Swift

    open class Subscription<T> : QueryViewModel<T>, QuerySubscribable where T : ParseObject
  • A default implementation of the QuerySubscribable protocol using closures for callbacks.

    See more

    Declaration

    Swift

    open class SubscriptionCallback<T> : QuerySubscribable where T : ParseObject
  • A default implementation of the CloudCodeObservable protocol. Suitable for ObjectObserved and can be used as a SwiftUI view model. Also can be used as a Combine publisher. See Apple’s documentation for more details.

    See more

    Declaration

    Swift

    open class CloudViewModel<T> : CloudObservable where T : ParseCloud
  • A default implementation of the QueryObservable protocol. Suitable for ObjectObserved and can be used as a SwiftUI view model. Also can be used as a Combine publisher. See Apple’s documentation for more details.

    See more

    Declaration

    Swift

    open class QueryViewModel<T> : QueryObservable where T : ParseObject