Merge pull request #493 from tjwudi/patch-1

Add import RCTBridge.h for event sending example
This commit is contained in:
Alexander Kotliarskyi 2015-03-30 14:48:58 -07:00
commit 02298b59e2

View File

@ -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`: The native module can signal events to JavaScript without being invoked directly. The easiest way to do this is to use `eventDispatcher`:
```objective-c ```objective-c
#import "RCTBridge.h"
#import "RCTEventDispatcher.h"
@implementation CalendarManager
@synthesize bridge = _bridge;
- (void)calendarEventReminderReceived:(NSNotification *)notification - (void)calendarEventReminderReceived:(NSNotification *)notification
{ {
NSString *eventName = notification.userInfo[@"name"]; NSString *eventName = notification.userInfo[@"name"];
[self.bridge.eventDispatcher sendAppEventWithName:@"EventReminder" [self.bridge.eventDispatcher sendAppEventWithName:@"EventReminder"
body:@{@"name": eventName}]; body:@{@"name": eventName}];
} }
@end
``` ```
JavaScript code can subscribe to these events: JavaScript code can subscribe to these events: