api modifications

This commit is contained in:
Peter 2016-03-25 20:50:04 -04:00
parent b1c6a23be4
commit d8c68394f9
2 changed files with 22 additions and 21 deletions

View File

@ -435,13 +435,17 @@ public class DDPClient: NSObject {
//
/**
Sends an unsubscribe request to the server.
Sends an unsubscribe request to the server.
- parameter name: The name of the subscription
- parameter callback: The closure to be executed when the server sends a 'ready' message
*/
- parameter name: The name of the subscription
*/
public func unsub(name: String) -> [String] {
return unsub(name, callback: nil)
public func unsub(withName name: String) -> [String] {
return findSubscription(name).map({id in
background.addOperationWithBlock() { self.sendMessage(["msg":"unsub", "id": id]) }
unsub(withId: id, callback: nil)
return id
})
}
/**
@ -453,15 +457,6 @@ public class DDPClient: NSObject {
- parameter callback: The closure to be executed when the server sends a 'ready' message
*/
public func unsub(name: String, callback: DDPCallback?) -> [String] {
return findSubscription(name).map({id in
print("UNSUBSCRIBING TO \(id)")
background.addOperationWithBlock() { self.sendMessage(["msg":"unsub", "id": id]) }
unsub(withId: id, callback: callback)
return id
})
}
public func unsub(withId id: String, callback: DDPCallback?) {
if let completionCallback = callback {
let completion = Completion(callback: completionCallback)

View File

@ -103,19 +103,25 @@ public class Meteor {
public static func subscribe(name:String, callback: DDPCallback?) -> String { return client.sub(name, params: nil, callback: callback) }
/**
Sends an unsubscribe request to the server.
Sends an unsubscribe request to the server. Unsubscibes to all subscriptions with the provided name.
*/
public static func unsubscribe(name:String) -> [String] { return client.unsub(name) }
public static func unsubscribe(name:String) -> [String] { return client.unsub(withName: name) }
/**
Sends an unsubscribe request to the server. If a callback is passed, the callback asynchronously
runs when the unsubscribe transaction is complete.
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.
*/
*/
public static func unsubscribe(withId id:String) { return client.unsub(withId: id, callback: nil) }
public static func unsubscribe(name:String, callback:DDPCallback?) -> [String] { return client.unsub(name, callback: callback) }
/**
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.
*/
public static func unsubscribe(withId id:String, callback:DDPCallback?) { return client.unsub(withId: id, callback: callback) }
/**
Calls a method on the server. If a callback is passed, the callback is asynchronously