Improve clarity of addListenerForEvent:hander:

This commit is contained in:
Scott Kyle 2016-01-12 17:07:48 -08:00
parent d7f80e22c8
commit 04ee234578
1 changed files with 4 additions and 1 deletions

View File

@ -96,7 +96,10 @@ extern "C" JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executo
}
- (void)addListenerForEvent:(NSString *)eventName handler:(RealmReactEventHandler)handler {
NSMutableOrderedSet *handlers = _eventHandlers[eventName] ?: (_eventHandlers[eventName] = [[NSMutableOrderedSet alloc] init]);
NSMutableOrderedSet *handlers = _eventHandlers[eventName];
if (!handlers) {
handlers = _eventHandlers[eventName] = [[NSMutableOrderedSet alloc] init];
}
[handlers addObject:handler];
}