mirror of
https://github.com/hanzoai/Detox.git
synced 2026-09-24 16:55:12 +00:00
51 lines
771 B
Objective-C
51 lines
771 B
Objective-C
//
|
|
// ShakeEventEmitter.m (example)
|
|
// Created by Asaf Korem (Wix.com) on 2025.
|
|
//
|
|
|
|
|
|
#import "ShakeEventEmitter.h"
|
|
|
|
@implementation ShakeEventEmitter {
|
|
BOOL hasListeners;
|
|
}
|
|
|
|
static ShakeEventEmitter *sharedInstance = nil;
|
|
|
|
RCT_EXPORT_MODULE();
|
|
|
|
+ (instancetype)sharedInstance {
|
|
return sharedInstance;
|
|
}
|
|
|
|
- (instancetype)init {
|
|
if (self = [super init]) {
|
|
sharedInstance = self;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
+ (BOOL)requiresMainQueueSetup {
|
|
return YES;
|
|
}
|
|
|
|
- (NSArray<NSString *> *)supportedEvents {
|
|
return @[@"ShakeEvent"];
|
|
}
|
|
|
|
- (void)startObserving {
|
|
hasListeners = YES;
|
|
}
|
|
|
|
- (void)stopObserving {
|
|
hasListeners = NO;
|
|
}
|
|
|
|
- (void)handleShake {
|
|
if (hasListeners) {
|
|
[self sendEventWithName:@"ShakeEvent" body:nil];
|
|
}
|
|
}
|
|
|
|
@end
|