mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-03 22:48:25 +08:00
add native module overriding
Differential Revision: D2700638 fb-gh-sync-id: a88ffaf864be848e1bba22e443d301e4623f04ec
This commit is contained in:
committed by
facebook-github-bot-3
parent
af753a8a4d
commit
9e30c3b218
@@ -22,7 +22,7 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||
* register themselves using {@link CxxModuleWrapper}.
|
||||
*/
|
||||
public interface NativeModule {
|
||||
public static interface NativeMethod {
|
||||
interface NativeMethod {
|
||||
void invoke(CatalystInstance catalystInstance, ReadableNativeArray parameters);
|
||||
String getType();
|
||||
}
|
||||
@@ -31,28 +31,36 @@ public interface NativeModule {
|
||||
* @return the name of this module. This will be the name used to {@code require()} this module
|
||||
* from javascript.
|
||||
*/
|
||||
public String getName();
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return methods callable from JS on this module
|
||||
*/
|
||||
public Map<String, NativeMethod> getMethods();
|
||||
Map<String, NativeMethod> getMethods();
|
||||
|
||||
/**
|
||||
* Append a field which represents the constants this module exports
|
||||
* to JS. If no constants are exported this should do nothing.
|
||||
*/
|
||||
public void writeConstantsField(JsonGenerator jg, String fieldName) throws IOException;
|
||||
void writeConstantsField(JsonGenerator jg, String fieldName) throws IOException;
|
||||
|
||||
/**
|
||||
* This is called at the end of {@link CatalystApplicationFragment#createCatalystInstance()}
|
||||
* after the CatalystInstance has been created, in order to initialize NativeModules that require
|
||||
* the CatalystInstance or JS modules.
|
||||
*/
|
||||
public void initialize();
|
||||
void initialize();
|
||||
|
||||
/**
|
||||
* Return true if you intend to override some other native module that was registered e.g. as part
|
||||
* of a different package (such as the core one). Trying to override without returning true from
|
||||
* this method is considered an error and will throw an exception during initialization. By
|
||||
* default all modules return false.
|
||||
*/
|
||||
boolean canOverrideExistingModule();
|
||||
|
||||
/**
|
||||
* Called before {CatalystInstance#onHostDestroy}
|
||||
*/
|
||||
public void onCatalystInstanceDestroy();
|
||||
void onCatalystInstanceDestroy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user