From d0eb446ee3e6d4bf8dba2fe1bafb6ae52e6ac7de Mon Sep 17 00:00:00 2001
From: Peter MIT With CocoaPods. Add the following line to your Podfile: Once you’ve created and started the Meteor todos server, set the url variable in AppDelegate.swift to ws://localhost:3000/websocket, then run the iOS app. The following pattern can be used to create custom collections backed by any datastore In this example, we’ll create a simple collection to hold a list of contacts. The first thing we’ll do is create an object to represent a contact. This object has four properties and a method named update that maps the fields NSDictionary to the struct’s properties. Update is called when an object is created and when an update is performed. Meteor will always transmit an id to identify the object that should be added, updated or removed, so objects that represent Meteor documents must always have an id field. Here we’re sticking to the MongoDB convention of naming our id _id.SwiftDDP
A client for Meteor servers, written in Swift
+version 0.3.0
License
Changelog
-0.3.0:
+
+
+
+
-
-Version 0.3.0 contains breaking changes
+
-
-unsubscribe(name:String)
. It now returns an array with the ids of the subscriptions you’ve unsubscribed to.0.2.2.1:
+
-
-0.2.1:
+
-
0.2.0:
-
-
+
Installation
Subscribe to a subset of a collection on the server
+Subscribe to a subset of a collection
+Meteor.subscribe("todos")
Meteor.subscribe("todos") {
@@ -270,6 +277,39 @@ Meteor.loginWithPassword("user@swiftddp.com", password: "********") { result, er
// Do something when the todos subscription is ready
}
Change the subscription’s parameters and manage your subscription with unsubscribe
+
+// Suppose you want to subscribe to a list of all cities and towns near a specific major city
+
+// Subscribe to cities near Boston
+let id1 = Meteor.subscribe("cities", ["lat": 42.358056 ,"lon": -71.063611]) {
+ // You are now subscribed to cities associated with the coordinates 42.358056, -71.063611
+ // id1 contains a key that allows you to cancel the subscription associated with
+ // the parameters ["lat": 42.358056 ,"lon": -71.063611]
+}
+
+// Subscribe to cities near Paris
+let id2 = Meteor.subscribe("cities", ["lat": 48.8567, "lon": 2.3508]){
+ // You are now subscribed to cities associated with the coordinates 48.8567, 2.3508
+ // id2 contains a key that allows you to cancel the subscription associated with
+ // the parameters ["lat": 48.8567 ,"lon": 2.3508]
+}
+
+// Subscribe to cities near New York
+let id3 = Meteor.subscribe("cities", ["lat": 40.7127, "lon": -74.0059]){
+ // You are now subscribed to cities associated with the coordinates 40.7127, -74.0059
+ // id3 contains a key that allows you to cancel the subscription associated with
+ // the parameters ["lat": 40.7127 ,"lon": -74.0059]
+}
+
+// When these subscriptions have completed, the collection associated with "cities" will now contain all
+// documents returned from the three subscriptions
+
+Meteor.unsubscribe(withId: id2)
+// Your collection will now contain cities near Boston and New York, but not Paris
+Meteor.unsubscribe("cities")
+// You are now unsubscribed to all subscriptions associated with the publication "cities"
+
Call a method on the server
Meteor.call("foo", [1, 2, 3, 4]) { result, error in
// Do something with the method result
@@ -320,7 +360,8 @@ Meteor.loginWithPassword("user@swiftddp.com", password: "********") { result, er
Example: Creating an array based custom collection
-The following pattern can be used to create custom collections backed by any datastore
+
+
@@ -418,6 +459,40 @@ Meteor.loginWithPassword("user@swiftddp.com", password: "********") { result, er
- (3) remove the contact from the local store if the server rejects the insert
Creating update and remove methods are also easy to create, and follow the same patern as insert. For a more extensive example of the patterns shown here, have a look at MeteorCollection.swift. MeteorCollection is an in-memory collection implementation suitable for simple applications.
+Version 0.3.0 contains breaking changes
+- You can now update a subscription by changing its parameters without first unsubscribing. This will subscribe the client to any documents associated with the new subscription and parameters. When you pass a new set of parameters to a subscription that you have previously subscribed to, you remain subscribed to any documents associated with that prior subscription.
+- The subscription method returns an id. To unsubscribe to documents associated with a specific set of parameters, you must unsubscribe with this id.
+- Unsubscribing by name now works differently. When unsubscribing by name, you unsubscribe to any and all subscriptions with that name.
+- You can no longer pass a callback to unsubscribe(name:String)
. It now returns an array with the ids of the subscriptions you’ve unsubscribed to.
Pull requests, feature requests are feedback are welcome. If you’re using SwiftDDP in a production app, let us know.
diff --git a/docs/docsets/SwiftDDP.tgz b/docs/docsets/SwiftDDP.tgz index 9a3ed958fcc085371b32d0b33242e8eb861c07a7..333dc2e790526647b57bb35c68c75275936c608e 100644 GIT binary patch literal 84109 zcmZs?V{|1z(={5~wl%SxoEQ_^&cwEDPBgJ66MJIYwrx8(!TIKSzW2R%t-J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