Last active
August 29, 2015 14:25
-
-
Save sferoze/3c8233d97c518be6c9c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func callTestMethod() { | |
Meteor.callMethodWithName("testMethod", parameters: "hello test method") { result in | |
println(result) | |
// You should receive back a string saying "I have received the following value hello test method" | |
} | |
func setupSubscription() { | |
let subscriptionLoader = SubscriptionLoader() | |
var childUserInfoSubscription = subscriptionLoader.addSubscriptionWithName("childUserInfo") | |
var testSubscription = subscriptionLoader.addSubscriptionWithName("testPub") | |
self.loadChildInfoSub(subscriptionLoader, subscription: childUserInfoSubscription, didFailWithError: NSError()) | |
self.loadTestSub(subscriptionLoader, subscription: testSubscription, didFailWithError: NSError()) | |
} | |
func loadChildInfoSub(subscriptionLoader: SubscriptionLoader, subscription: METSubscription, didFailWithError error: NSError) { | |
subscriptionLoader.delegate = self | |
subscriptionLoader.whenReady { | |
var families = Meteor.database.collectionWithName("families") | |
var myFamilies: NSArray = families.allDocuments | |
println(myFamilies[0].valueForKey("fields")!["name"]!) | |
var todos = Meteor.database.collectionWithName("todos") | |
var myTodos: NSArray = todos.allDocuments | |
println(myTodos[0].valueForKey("fields")!["todo"]!) | |
// Other collection names are "rewards", "calendarevents" | |
} | |
} | |
func loadTestSub(subscriptionLoader: SubscriptionLoader, subscription: METSubscription, didFailWithError error: NSError) { | |
subscriptionLoader.delegate = self | |
subscriptionLoader.whenReady { | |
var test = Meteor.database.collectionWithName("test") | |
var aTest: NSArray = test.allDocuments | |
println(aTest[0].valueForKey("fields")!["testKey"]!) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment