BaseJavaModule

abstract class BaseJavaModule : NativeModule

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:

  1. primitives (boolean, int, float, double
  2. String mapped from JS string
  3. ReadableArray mapped from JS Array
  4. ReadableMap mapped from JS Object
  5. 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.

Inheritors

Constructors

Link copied to clipboard
constructor()
constructor(@Nullable reactContext: ReactApplicationContext)

Properties

Link copied to clipboard
val METHOD_TYPE_ASYNC: String = "async"
Link copied to clipboard
val METHOD_TYPE_PROMISE: String = "promise"
Link copied to clipboard
val METHOD_TYPE_SYNC: String = "sync"

Functions

Link copied to clipboard
Return true if you intend to override some other native module that was registered e.g.
Link copied to clipboard
Link copied to clipboard
abstract fun getName(): String
Link copied to clipboard
open fun initialize()
This method is called after ReactApplicationContext has been created.
Link copied to clipboard
open fun invalidate()
The CatalystInstance is going away with Venice.
Link copied to clipboard
Allow NativeModule to clean up.