Skip to content

Instantly share code, notes, and snippets.

@sferoze
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sferoze/3c8233d97c518be6c9c4 to your computer and use it in GitHub Desktop.
Save sferoze/3c8233d97c518be6c9c4 to your computer and use it in GitHub Desktop.
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