Files
projet_gestion_commande/frontend-admin/node_modules/react-native-webview/apple/RNCWebViewDecisionManager.m
T
2026-02-07 22:33:02 +01:00

48 lines
1.1 KiB
Objective-C

#import "RNCWebViewDecisionManager.h"
@implementation RNCWebViewDecisionManager
@synthesize nextLockIdentifier;
@synthesize decisionHandlers;
+ (id)getInstance {
static RNCWebViewDecisionManager *lockManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
lockManager = [[self alloc] init];
});
return lockManager;
}
- (int)setDecisionHandler:(DecisionBlock)decisionHandler {
int lockIdentifier = self.nextLockIdentifier++;
[self.decisionHandlers setObject:decisionHandler forKey:@(lockIdentifier)];
return lockIdentifier;
}
- (void) setResult:(BOOL)shouldStart
forLockIdentifier:(int)lockIdentifier {
DecisionBlock handler = [self.decisionHandlers objectForKey:@(lockIdentifier)];
if (handler == nil) {
RCTLogWarn(@"Lock not found");
return;
}
handler(shouldStart);
[self.decisionHandlers removeObjectForKey:@(lockIdentifier)];
}
- (id)init {
if (self = [super init]) {
self.nextLockIdentifier = 1;
self.decisionHandlers = [[NSMutableDictionary alloc] init];
}
return self;
}
- (void)dealloc {}
@end