RNEventEmitter.m 961 Bytes
Newer Older
yogevbd's avatar
WIP  
yogevbd committed
1 2 3 4 5 6 7
#import "RNEventEmitter.h"

@implementation RNEventEmitter

RCT_EXPORT_MODULE();

-(NSArray<NSString *> *)supportedEvents {
yogevbd's avatar
WIP  
yogevbd committed
8 9 10 11 12 13 14
    return @[RNRegistered,
             RNRegistrationFailed,
             RNPushKitRegistered,
             RNNotificationReceivedForeground,
             RNNotificationReceivedBackground,
             RNNotificationOpened,
             RNActionTriggered];
yogevbd's avatar
WIP  
yogevbd committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
}

# pragma mark public

+ (instancetype)sharedInstance {
    static RNEventEmitter *sharedInstance = nil;
    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken, ^{
        sharedInstance = [[RNEventEmitter alloc] init];
    });
    return sharedInstance;
}

+ (void)sendEvent:(NSString *)event body:(NSDictionary *)body {
    [[self sharedInstance] send:event body:body];
}


# pragma mark private

- (void)send:(NSString *)eventName body:(id)body {
    if (self.bridge == nil) {
        return;
    }
    [self sendEventWithName:eventName body:body];
}

@end