2 RN GO
Pedro Pombeiro edited this page 2018-10-08 16:52:32 +02:00

Function calls

All status-react to status-go calls are centralized in StatusModule (Android) or RCTStatus (iOS). General structure of methods is:

  • caller provides a callback
  • check for availability of current Activity
  • if available: call a static method on StatusGo via an ExecutorService (or sometimes a Thread) and use its result as callback payload
  • else: invoke callback with false as payload

From RN perspective calls do not block, result is provided through callback execution.

StatusGo is a C library generated from Go side embedded in Status apps. On Android it is packaged as a JNI aar (generated using xgo).

StatusGo directly exposes status-go methods marked for exportation. Those methods are defined in lib/library.go and marked as export. go side calls are then dispatched to api/backend.go.

Data is provided to the Go layer as primitive types and retrieved RN side as JSON.

Events

status-go can directly send events that will be received RN side. It achieves that by directly calling signal-event using some JNI glue.

StatusModule is also used as a react context listener that emits events to the RN layer.

status-react listens to those events via gethEvent then dispatched by a re-frame handler.