This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
NativeModules, | |
NativeEventEmitter, | |
} from 'react-native'; | |
const { | |
NMWithEmitterOne, | |
NMWithEmitterTwo, | |
NMWithEmitterN, | |
} = NativeModules; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation CalendarManager | |
{ | |
bool hasListeners; | |
} | |
// Will be called when this module's first listener is added. | |
-(void)startObserving { | |
hasListeners = YES; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)sessionDidConnect:(Session*)session { | |
[[NSNotificationCenter defaultCenter] | |
postNotificationName:@"onSessionConnect" | |
object:nil | |
userInfo:@{@"sessionId": session.sessionId}]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "EventEmitterModule.h" | |
@implementation EventEmitterModule | |
{ | |
bool hasListeners; | |
} | |
RCT_EXPORT_MODULE(); | |
- (NSArray<NSString *> *)supportedEvents { | |
return @[@"onSessionDidConnect"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <React/RCTBridgeModule.h> | |
#import <React/RCTEventEmitter.h> | |
@interface EventEmitterModule : RCTEventEmitter <RCTBridgeModule> | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subscription.remove(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
NativeModules, | |
Platform, | |
NativeEventEmitter, | |
DeviceEventEmitter, | |
} from 'react-native'; | |
export default Platform.select({ | |
ios: new NativeEventEmitter(NativeModules.ModuleWithEmitter), | |
android: DeviceEventEmitter, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NativeEventEmitter, NativeModules } from 'react-native'; | |
const { ModuleWithEmitter } = NativeModules; | |
const eventEmitter = new NativeEventEmitter(ModuleWithEmitter); | |
const onSessionConnect = (event) => { | |
console.log(event); | |
} | |
const subscription = eventEmitter.addListener('onSessionConnect', onSessionConnect); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[self sendEventWithName:@"onSessionConnect" body:@{@"sessionId": session.sessionId}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ModuleWithEmitter.h" | |
@implementation ModuleWithEmitter | |
- (NSArray<NSString *> *)supportedEvents { | |
return @[@"onSessionConnect"]; | |
} | |
@end |
NewerOlder