-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to lazy load Native Java Modules
Summary: Utilizes the build time annotation processor ReactModuleSpecProcessor that creates ReactModuleInfos for modules annotated with ReactModule and listed in the ReactModuleList annotation of LazyReactPackages. This way we don't have to instantiate the native modules to get the name, canOverrideExistingModule, and supportsWebWorkers values of the native modules. In the NativeModuleRegistry, we either store these ReactModuleInfos inside of a ModuleHolder or if we can't get the ReactModuleInfo for a specific module we instantiate that module to get the values (as we previously did) to store in a LegacyModuleInfo. Reviewed By: astreet Differential Revision: D3796561 fbshipit-source-id: f8fb9b4993f59b51ce595eb2f2c3425129b28ce5
- Loading branch information
1 parent
1f9b765
commit 797ca6c
Showing
16 changed files
with
500 additions
and
120 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
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
24 changes: 24 additions & 0 deletions
24
ReactAndroid/src/main/java/com/facebook/react/EagerModuleProvider.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
package com.facebook.react; | ||
|
||
import javax.inject.Provider; | ||
|
||
import com.facebook.react.bridge.NativeModule; | ||
|
||
/** | ||
* Provider for an already initialized and non-lazy NativeModule. | ||
*/ | ||
public class EagerModuleProvider implements Provider<NativeModule> { | ||
|
||
private final NativeModule mModule; | ||
|
||
public EagerModuleProvider(NativeModule module) { | ||
mModule = module; | ||
} | ||
|
||
@Override | ||
public NativeModule get() { | ||
return mModule; | ||
} | ||
} |
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
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
Oops, something went wrong.
2 comments
on commit 797ca6c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how to make use of this commit in an RN android app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also trying to figure out how to make use of this commit (@vonovak). For many developers they use the default build tool Gradle
but there's no clear way to use annotationProcessor
which is where I'm somewhat stuck
I'm not sure I agree with this change, because it seems inconsistent with how the
onResume()
method of Android Activities work.But even if we want to do it this way, isn't it inconsistent that
onHostPause()
is not also called immediately when added while the app's state isBEFORE_RESUME
? Note also that without this addition, it seems like there's no way for a consumer to detect specifically the first time an app transitions fromBEFORE_RESUME
toRESUMED
, as opposed to the first time an app is in theRESUMED
state.