//
//  CustomEventEmitter.m
//  AwesomeProject3
//
//  Created by Macbook Pro on 10/07/2023.
//

// YourCustomEventEmitter.h

#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
#import "CustomEventEmitter.h"


@implementation CustomEventEmitter

RCT_EXPORT_MODULE(CustomEventEmitter);

+ (id)allocWithZone:(NSZone *)zone {
    static CustomEventEmitter *sharedInstance = nil;
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    sharedInstance = [super allocWithZone:zone];
  });
  return sharedInstance;
}

//RCT_EXPORT_MODULE();
//
- (NSArray<NSString *> *)supportedEvents {
  return @[@"onReadyyy" , @"pushDelivered"]; // Event name(s) you want to emit
}

- (void)sendDataToReactNative:(NSString *)eventName body:(id)body {

    NSLog(@"CustomEventsEmitter sendEventName emitting event: %@", eventName);
    [self sendEventWithName:eventName   body:body];

}


-(void)emitPushDeliveredEvent:(NSString*)value {
    CustomEventEmitter *instance = [[CustomEventEmitter alloc] init];
    NSLog(@"emitPushDeliveredEvent called");
    
    [instance sendDataToReactNative:@"onReadyyy" body:value];
    //[customEventsEmitter sendEventWithName:@"pushDelivered" body:value];}

}




@end
