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
nameThe 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
nameThe name of the subscription.
paramsAn 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
nameThe name of the subscription.
paramsAn object containing method arguments, if any.
callbackThe 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
nameThe name of the subscription.
callbackThe 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
nameThe 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
idAn 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
idAn id string returned from a subscription request
callbackThe 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
nameThe name of the method
paramsAn array containing method arguments, if any
callbackThe 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
urlThe url of a Meteor server
emailA string email address associated with a Meteor account
passwordA 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
urlThe 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
urlThe url of a Meteor server
callbackAn 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
emailAn email string
passwordA password string
callbackA 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
emailAn email string
passwordA password string
profileA dictionary containing the user profile
callbackA 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
usernameA username string
passwordA password string
emailAn email to be associated with the account
profileA dictionary containing the user profile
callbackA 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
emailAn email string
passwordA password string
callbackA 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
emailAn email string
passwordA 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
usernameA username string
passwordA password string
callbackA 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
viewControllerA 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
viewControllerA view controller from which to launch the OAuth modal dialog
clientIdThe 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
viewControllerA view controller from which to launch the OAuth modal dialog
clientIdThe 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
viewControllerA view controller from which to launch the OAuth modal dialog
clientIdThe 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
callbackAn 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
Meteor Class Reference