Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Roll out RCTNetworking extraneous NativeModule call removal
Summary: ## Context Every time we call RCTNetworking.sendRequest(), we [set up six event listeners inside XMLHttpRequest](https://fburl.com/diffusion/85k6ou5w) by calling RCTNetworking.addListener(). Seeing how RCTNetworking.addListener() is implemented, each call results in two async NativeModule call: [one to addListener()](https://fburl.com/diffusion/ng21jek6), and [another to removeEventListener()](https://fburl.com/diffusion/nua3y973). For RCTNetworking, both of these NativeModule calls are unnecessary, as explained in D24272663 (dabca52) > RCTNetworking.startObserving and RCTNetworking.stopObserving don't exist. The main purpose of RCTEventEmitter.addListener is to call these methods, and increment the _listeners counter, so that we can start dispatching events when _listeners > 0. In D24272560 (82187bf), I made RCTEventEmitter dispatch events even when _listeners <= 0. This is sufficient for us to stop calling these two RCTNetworking methods entirely. Therefore, this experiment gets rid of on average 6-8 NativeModule method calls for every network call we make in React Native on iOS. Reviewed By: PeteTheHeat Differential Revision: D25618704 fbshipit-source-id: 0da20475a0882ed737cf32de27f266fd2cd016af
- Loading branch information