-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor TurboModule filtering in NativeModuleRegistryBuilder
Summary: ## Context `NativeModuleRegistryBuilder` calls `TurboReactPackage.getNativeModuleIterator()` to access ModuleHolders for all the NativeModules in the `TurboReactPackage`. We then filter out the ModuleHolders that contain `TurboModules`, before using that list to make create the `NativeModuleRegistry`. ## Problem Creating `ModuleHolders` has the side-effect of actually creating the NativeModule if it requires eager initialization. See [ModuleHolder.java](https://fburl.com/diffusion/4avdtio0): ``` class ModuleHolder { // ... public ModuleHolder(ReactModuleInfo moduleInfo, Provider<? extends NativeModule> provider) { mName = moduleInfo.name(); mProvider = provider; mReactModuleInfo = moduleInfo; if (moduleInfo.needsEagerInit()) { mModule = create(); // HERE! } } ``` So, we need to filter out TurboModules before we even create ModuleHolders. Changelog: [Android][Fixed] - Refactor TurboModule filtering in NativeModuleRegistryBuilder Reviewed By: PeteTheHeat, mdvacca Differential Revision: D18814010 fbshipit-source-id: a120d2b619b9280ba70e21d131dccc5a9fc6346d
- Loading branch information
1 parent
e362470
commit d9deee2
Showing
2 changed files
with
38 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters