Dispatch events even when there are no listeners

Summary:
## Rationale
For every 1 call to RCTNetworking.sendRequest, we execute 6 calls to RCTNetworking.addListener. This is followed by at least one call to RCTNetworking.removeListeners. Aside from incrementing and decrementing the `_listeners` integer, these two methods accomplish nothing else: RCTNetworking doesn't implement the `startObserving` and `stopObserving` methods.

This diff makes RCTEventEmitter dispatch events without looking at the listeners integer. In the future, this will allow us to stop making these ~8 unnecessary NativeModule calls for every Network request we send.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24272560

fbshipit-source-id: 7996eba5abfa4669a89c43a3ffa536c0faa214a8
This commit is contained in:
Ramanpreet Nara
2020-10-14 21:05:38 -07:00
committed by Facebook GitHub Bot
parent fb14fd42b3
commit 82187bfb6b
3 changed files with 28 additions and 3 deletions
+1 -1
View File
@@ -159,7 +159,7 @@ RCT_EXPORT_MODULE()
- (instancetype)initWithHandlersProvider:(NSArray<id<RCTURLRequestHandler>> * (^)(void))getHandlers
{
if (self = [super init]) {
if (self = [super initWithDisabledObservation]) {
_handlersProvider = getHandlers;
}
return self;