Skip to content

Commit

Permalink
Merge pull request facebook#493 from tjwudi/patch-1
Browse files Browse the repository at this point in the history
Add import RCTBridge.h for event sending example
  • Loading branch information
frantic committed Mar 30, 2015
2 parents 86a1e70 + 4f49271 commit 02298b5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/NativeModulesIOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,21 @@ Note that the constants are exported only at initialization time, so if you chan
The native module can signal events to JavaScript without being invoked directly. The easiest way to do this is to use `eventDispatcher`:

```objective-c
#import "RCTBridge.h"
#import "RCTEventDispatcher.h"

@implementation CalendarManager

@synthesize bridge = _bridge;

- (void)calendarEventReminderReceived:(NSNotification *)notification
{
NSString *eventName = notification.userInfo[@"name"];
[self.bridge.eventDispatcher sendAppEventWithName:@"EventReminder"
body:@{@"name": eventName}];
}

@end
```
JavaScript code can subscribe to these events:
Expand Down

0 comments on commit 02298b5

Please sign in to comment.