Meteor
public class Meteor
Meteor is a class to simplify communicating with and consuming MeteorJS server services
-
client is a singleton instance of DDPClient
Declaration
Swift
public static let client = Meteor.Client() // Client is a singleton object
-
returns a Meteor collection, if it exists
Declaration
Swift
public static func collection(name:String) -> MeteorCollectionType?
-
Sends a subscription request to the server.
Declaration
Swift
public static func subscribe(name:String) -> String { return client.sub(name, params:nil) }
Parameters
name
The name of the subscription.
-
Sends a subscription request to the server.
Declaration
Swift
public static func subscribe(name:String, params:[AnyObject]) -> String { return client.sub(name, params:params) }
Parameters
name
The name of the subscription.
params
An object containing method arguments, if any.
-
Sends a subscription request to the server. If a callback is passed, the callback asynchronously runs when the client receives a ‘ready’ message indicating that the initial subset of documents contained in the subscription has been sent by the server.
Declaration
Swift
public static func subscribe(name:String, params:[AnyObject]?, callback: DDPCallback?) -> String { return client.sub(name, params:params, callback:callback) }
Parameters
name
The name of the subscription.
params
An object containing method arguments, if any.
callback
The closure to be executed when the server sends a ‘ready’ message.
-
Sends a subscription request to the server. If a callback is passed, the callback asynchronously runs when the client receives a ‘ready’ message indicating that the initial subset of documents contained in the subscription has been sent by the server.
Declaration
Swift
public static func subscribe(name:String, callback: DDPCallback?) -> String { return client.sub(name, params: nil, callback: callback) }
Parameters
name
The name of the subscription.
callback
The closure to be executed when the server sends a ‘ready’ message.
-
Sends an unsubscribe request to the server. Unsubscibes to all subscriptions with the provided name. - parameter name: The name of the subscription.
Declaration
Swift
public static func unsubscribe(name:String) -> [String] { return client.unsub(withName: name) }
Parameters
name
The name of the subscription.
-
Sends an unsubscribe request to the server using a subscription id. This allows fine-grained control of subscriptions. For example, you can unsubscribe to specific combinations of subscriptions and subscription parameters. - parameter id: An id string returned from a subscription request
Declaration
Swift
public static func unsubscribe(withId id:String) { return client.unsub(withId: id, callback: nil) }
Parameters
id
An id string returned from a subscription request
-
Sends an unsubscribe request to the server using a subscription id. This allows fine-grained control of subscriptions. For example, you can unsubscribe to specific combinations of subscriptions and subscription parameters. If a callback is passed, the callback asynchronously runs when the unsubscribe transaction is complete. - parameter id: An id string returned from a subscription request - parameter callback: The closure to be executed when the method has been executed
Declaration
Swift
public static func unsubscribe(withId id:String, callback:DDPCallback?) { return client.unsub(withId: id, callback: callback) }
Parameters
id
An id string returned from a subscription request
callback
The closure to be executed when the method has been executed
-
Calls a method on the server. If a callback is passed, the callback is asynchronously executed when the method has completed. The callback takes two arguments: result and error. It the method call is successful, result contains the return value of the method, if any. If the method fails, error contains information about the error.
Declaration
Swift
public static func call(name:String, params:[AnyObject]?, callback:DDPMethodCallback?) -> String?
Parameters
name
The name of the method
params
An array containing method arguments, if any
callback
The closure to be executed when the method has been executed
-
Call a single function to establish a DDP connection, and login with email and password
Declaration
Swift
public static func connect(url:String, email:String, password:String)
Parameters
url
The url of a Meteor server
email
A string email address associated with a Meteor account
password
A string password
-
Connect to a Meteor server and resume a prior session, if the user was logged in
Declaration
Swift
public static func connect(url:String)
Parameters
url
The url of a Meteor server
-
Connect to a Meteor server and resume a prior session, if the user was logged in
Declaration
Swift
public static func connect(url:String, callback:DDPCallback?)
Parameters
url
The url of a Meteor server
callback
An optional closure to be executed after the connection is established
-
Creates a user account on the server with an email and password
Declaration
Swift
public static func signupWithEmail(email: String, password: String, callback: DDPMethodCallback?)
Parameters
email
An email string
password
A password string
callback
A closure with result and error parameters describing the outcome of the operation
-
Creates a user account on the server with an email and password
Declaration
Swift
public static func signupWithEmail(email: String, password: String, profile: NSDictionary, callback: DDPMethodCallback?)
Parameters
email
An email string
password
A password string
profile
A dictionary containing the user profile
callback
A closure with result and error parameters describing the outcome of the operation
-
Creates a user account on the server with a username and password
Declaration
Swift
public static func signupWithUsername(username: String, password: String, email: String? = nil, profile: NSDictionary? = nil, callback: DDPMethodCallback? = nil)
Parameters
username
A username string
password
A password string
email
An email to be associated with the account
profile
A dictionary containing the user profile
callback
A closure with result and error parameters describing the outcome of the operation
-
Logs a user into the server using an email and password
Declaration
Swift
public static func loginWithPassword(email:String, password:String, callback:DDPMethodCallback?)
Parameters
email
An email string
password
A password string
callback
A closure with result and error parameters describing the outcome of the operation
-
Logs a user into the server using an email and password
Declaration
Swift
public static func loginWithPassword(email:String, password:String)
Parameters
email
An email string
password
A password string
-
Logs a user into the server using a username and password
Declaration
Swift
public static func loginWithUsername(username:String, password:String, callback:DDPMethodCallback? = nil)
Parameters
username
A username string
password
A password string
callback
A closure with result and error parameters describing the outcome of the operation
-
Logs a user into the server using Twitter
Declaration
Swift
public static func loginWithTwitter<T: UIViewController>(viewController: T)
Parameters
viewController
A view controller from which to launch the OAuth modal dialog
-
Logs a user into the server using Facebook
Declaration
Swift
public static func loginWithFacebook<T: UIViewController>(clientId: String, viewController: T)
Parameters
viewController
A view controller from which to launch the OAuth modal dialog
clientId
The apps client id, provided by the service (Facebook, Google, etc.)
-
Logs a user into the server using Github
Declaration
Swift
public static func loginWithGithub<T: UIViewController>(clientId: String, viewController: T)
Parameters
viewController
A view controller from which to launch the OAuth modal dialog
clientId
The apps client id, provided by the service (Facebook, Google, etc.)
-
Logs a user into the server using Google
Declaration
Swift
public static func loginWithGoogle<T: UIViewController>(clientId: String, viewController: T)
Parameters
viewController
A view controller from which to launch the OAuth modal dialog
clientId
The apps client id, provided by the service (Facebook, Google, etc.)
-
Logs a user out of the server and executes a callback when the logout process has completed
Declaration
Swift
public static func logout(callback:DDPMethodCallback?)
Parameters
callback
An optional closure to be executed after the client has logged out
-
Logs a user out of the server
Declaration
Swift
public static func logout()
-
Meteor.Client is a subclass of DDPClient that facilitates interaction with the MeteorCollection class
See moreDeclaration
Swift
public class Client: DDPClient