iOS typo fix

This commit is contained in:
pengfei.zhou 2021-08-24 10:32:32 +08:00 committed by osborn
parent e0d76d218d
commit 04cfbf49d8

View File

@ -23,24 +23,24 @@
@interface DoricNotificationPlugin () @interface DoricNotificationPlugin ()
@property(nonatomic, strong) NSMutableDictionary<NSString *, id> *observers; @property(nonatomic, strong) NSMutableDictionary<NSString *, id> *observers;
@property (nonatomic, strong) dispatch_queue_t syncQuene; @property(nonatomic, strong) dispatch_queue_t syncQueue;
@end @end
@implementation DoricNotificationPlugin @implementation DoricNotificationPlugin
- (NSDictionary *)observers { - (NSMutableDictionary<NSString *, id> *)observers {
if (!_observers) { if (!_observers) {
_observers = [NSMutableDictionary new]; _observers = [NSMutableDictionary new];
} }
return _observers; return _observers;
} }
- (dispatch_queue_t)syncQuene { - (dispatch_queue_t)syncQueue {
if (!_syncQuene) { if (!_syncQueue) {
_syncQuene = dispatch_queue_create("pub.doric.plugin.notification", DISPATCH_QUEUE_CONCURRENT); _syncQueue = dispatch_queue_create("pub.doric.plugin.notification", DISPATCH_QUEUE_CONCURRENT);
} }
return _syncQuene; return _syncQueue;
} }
- (void)publish:(NSDictionary *)dic withPromise:(DoricPromise *)promise { - (void)publish:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
@ -80,18 +80,17 @@ - (void)subscribe:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
[currentPromise resolve:note.userInfo]; [currentPromise resolve:note.userInfo];
}]; }];
dispatch_barrier_async(self.syncQuene, ^{ dispatch_barrier_async(self.syncQueue, ^{
[self.observers setObject:observer forKey:callbackId]; self.observers[callbackId] = observer;
}); });
[promise resolve:callbackId]; [promise resolve:callbackId];
} }
- (void)unsubscribe:(NSString *)subscribeId withPromise:(DoricPromise *)promise { - (void)unsubscribe:(NSString *)subscribeId withPromise:(DoricPromise *)promise {
dispatch_barrier_async(self.syncQuene, ^{ dispatch_barrier_async(self.syncQueue, ^{
id observer = [self.observers objectForKey:subscribeId]; id observer = self.observers[subscribeId];
[[NSNotificationCenter defaultCenter] removeObserver:observer]; [[NSNotificationCenter defaultCenter] removeObserver:observer];
[self.observers removeObjectForKey:subscribeId]; [self.observers removeObjectForKey:subscribeId];
[promise resolve:nil]; [promise resolve:nil];
}); });
} }