mirror of
https://github.com/status-im/react-native.git
synced 2025-01-28 18:25:06 +00:00
Merge pull request #493 from tjwudi/patch-1
Add import RCTBridge.h for event sending example
This commit is contained in:
commit
02298b59e2
@ -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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user