Client
@objc(PFLiveQueryClient)
open class Client : NSObject
extension Client: WebSocketDelegate
This is the ‘advanced’ view of live query subscriptions. It allows you to customize your subscriptions to a live query server, have connections to multiple servers, cleanly handle disconnect and reconnect.
-
Creates a Client which automatically attempts to connect to the custom parse-server URL set in Parse.currentConfiguration().
Declaration
Swift
public override convenience init()
-
Creates a client which will connect to a specific server with an optional application id and client key
Declaration
Swift
@objc(initWithServer:applicationId:clientKey:) public init(server: String, applicationId: String? = nil, clientKey: String? = nil)
Parameters
server
The server to connect to
applicationId
The application id to use
clientKey
The client key to use
-
Gets or sets shared live query client to be used for default subscriptions
Declaration
Swift
@objc(sharedClient) public static var shared: Client! { get set }
-
Registers a query for live updates, using the default subscription handler
Declaration
Swift
public func subscribe<T>( _ query: PFQuery<T>, subclassType: T.Type = T.self ) -> Subscription<T>
Parameters
query
The query to register for updates.
subclassType
The subclass of PFObject to be used as the type of the Subscription. This parameter can be automatically inferred from context most of the time
Return Value
The subscription that has just been registered
-
Registers a query for live updates, using a custom subscription handler
Declaration
Swift
public func subscribe<T>( _ query: PFQuery<T.PFObjectSubclass>, handler: T ) -> T where T: SubscriptionHandling
Parameters
query
The query to register for updates.
handler
A custom subscription handler.
Return Value
Your subscription handler, for easy chaining.
-
Updates an existing subscription with a new query. Upon completing the registration, the subscribe handler will be called with the new query
Declaration
Swift
public func update<T>( _ handler: T, toQuery query: PFQuery<T.PFObjectSubclass> ) where T: SubscriptionHandling
Parameters
handler
The specific handler to update.
query
The new query for that handler.
-
Unsubscribes all current subscriptions for a given query.
Declaration
Swift
@objc(unsubscribeFromQuery:) public func unsubscribe(_ query: PFQuery<PFObject>)
Parameters
query
The query to unsubscribe from.
-
Unsubscribes from a specific query-handler pair.
Declaration
Swift
public func unsubscribe<T>(_ query: PFQuery<T.PFObjectSubclass>, handler: T) where T : SubscriptionHandling
Parameters
query
The query to unsubscribe from.
handler
The specific handler to unsubscribe from.
-
Reconnects this client to the server.
This will disconnect and resubscribe all existing subscriptions. This is not required to be called the first time you use the client, and should usually only be called when an error occurs.
Declaration
Swift
@objc(reconnect) public func reconnect()
-
Explicitly disconnects this client from the server.
This does not remove any subscriptions - if you
reconnect()
your existing subscriptions will be restored. Use this if you wish to dispose of the live query client.Declaration
Swift
@objc(disconnect) public func disconnect()
-
Registers a query for live updates, using a custom subscription handler.
Declaration
Swift
@objc(subscribeToQuery:withHandler:) public func _PF_objc_subscribe( _ query: PFQuery<PFObject>, handler: ObjCCompat_SubscriptionHandling ) -> ObjCCompat_SubscriptionHandling
Parameters
query
The query to register for updates.
handler
A custom subscription handler.
Return Value
The subscription that has just been registered.
-
Registers a query for live updates, using the default subscription handler.
Declaration
Swift
@objc(subscribeToQuery:) public func _PF_objc_subscribe(_ query: PFQuery<PFObject>) -> ObjCCompat.Subscription
Parameters
query
The query to register for updates.
Return Value
The subscription that has just been registered.
-
Unsubscribes a specific handler from a query.
Declaration
Swift
@objc(unsubscribeFromQuery:withHandler:) public func _PF_objc_unsubscribe(_ query: PFQuery<PFObject>, subscriptionHandler: ObjCCompat_SubscriptionHandling)
Parameters
query
The query to unsubscribe from.
handler
The specific handler to unsubscribe from.