Base Java Module
Base class for Catalyst native modules whose implementations are written in Java. Default implementations for initialize and onCatalystInstanceDestroy are provided for convenience. Subclasses which override these don't need to call super
in case of overriding those methods as implementation of those methods is empty.
BaseJavaModules can be linked to Fragments' lifecycle events, CatalystInstance creation and destruction, by being called on the appropriate method when a life cycle event occurs.
Native methods can be exposed to JS with ReactMethod annotation. Those methods may only use limited number of types for their arguments:
- primitives (boolean, int, float, double
- String mapped from JS string
- ReadableArray mapped from JS Array
- ReadableMap mapped from JS Object
- Callback mapped from js function and can be used only as a last parameter or in the case when it express success &error callback pair as two last arguments respectively.
All methods exposed as native to JS with ReactMethod annotation must return
void
.
Please note that it is not allowed to have multiple methods annotated with ReactMethod with the same name.