Permalink
Browse files

Add pubsub channel example.

  • Loading branch information...
1 parent e2c9c3d commit 91749688cbb374d121fce67ce19e5da76a059478 @dgraham dgraham committed Mar 12, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 README.md
View
17 README.md
@@ -72,6 +72,23 @@ NSMutableDictionary *comment = [NSMutableDictionary dictionaryWithObjectsAndKeys
}];
```
+### Pubsub Channels
+
+```objectivec
+VCChannel *comments = [app channelForName:@"comments"];
+
+// subscribe so messages published to the channel will be passed to the callback block
+[comments subscribe:^(NSMutableDictionary *message) {
+ NSLog(@"comment: received on channel %@", message);
+ // unsubscribe from the channel after one message
+ [comments unsubscribe];
+}];
+
+// publish a comment to the channel
+NSMutableDictionary *comment = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"This is a comment!", @"text", nil];
+[comments publish:comment];
+```
+
## Dependencies
This library requires Xcode 4.2 and iOS 5.0 or better.

0 comments on commit 9174968

Please sign in to comment.