Skip to content

Commit

Permalink
Add example of using the onReadyState event
Browse files Browse the repository at this point in the history
  • Loading branch information
neilco committed Jun 1, 2016
1 parent deebb76 commit f45b628
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions EventViewer/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ - (void)viewDidLoad
[super viewDidLoad];

EventSource *source = [EventSource eventSourceWithURL:[NSURL URLWithString:@"http://127.0.0.1:8000/"]];
[source onReadyStateChanged:^(Event *event) {
NSLog(@"READYSTATE: %@", event);
}];

[source addEventListener:@"hello_event" handler:^(Event *e) {
NSLog(@"%@: %@", e.event, e.data);
}];
Expand Down

0 comments on commit f45b628

Please sign in to comment.