Electrode Native
v0.41
v0.41
  • Introduction
  • INTRODUCTION
    • Overview
      • What is Electrode Native
      • Why use Electrode Native
      • What is a MiniApp
      • Electrode Native workflow
      • Native dependencies management
      • JS/Native communication
      • Requirements
      • Upgrading Electrode Native
      • Contributing
  • REFERENCE
    • Bundle Store
    • Composite
    • Container
      • What's inside
      • Publication
      • Integration
      • Initialization
      • Launching MiniApps
    • Cauldron
      • Structure
      • Setup
      • Compatibility checks
      • Guidelines
    • Manifest
      • Override
      • Native Modules
      • Configurable Modules
    • Runner
    • APIs
      • Project Generation
      • Implementation
      • Versioning
      • Guidelines
    • Bridge
      • Message Types
      • Communication
      • Leveraging APIs
    • CLI
      • Global CLI
      • Local CLI
    • GLOSSARY
  • GUIDES
    • Debugging multiple MiniApps
  • CLI COMMANDS
    • add
    • bundlestore
      • create
      • delete
      • upload
      • use
    • binarystore
      • add
      • get
      • remove
    • code-push
      • patch
      • release
      • promote
    • compat-check
    • create-api-impl
    • create-api
    • create-composite
    • create-container
    • create-plugin-config
    • publish-container
    • transform-container
    • create-miniapp
    • link
    • regen-api
    • regen-api-impl
    • run-android
    • run-ios
    • start
    • unlink
    • upgrade-miniapp
    • cauldron add
      • file
      • jsapiimpls
      • miniapps
      • nativeapp
    • cauldron config
      • get
    • cauldron del
      • file
      • jsapiimpls
      • miniapps
      • nativeapp
    • cauldron get
      • config
      • dependency
      • nativeapp
    • cauldron repo
      • add
      • clear
      • current
      • list
      • remove
      • use
    • cauldron update
      • file
      • jsapiimpls
      • miniapps
      • nativeapp
    • cauldron batch
    • cauldron regen-container
    • cauldron upgrade
    • cauldron why
    • github
      • github create-ref
      • github delete-ref
      • github align-dependencies
    • platform
      • plugins
        • list
        • search
      • config
        • set
        • get
        • del
        • list
      • install
      • versions
      • uninstall
      • use
Powered by GitBook
On this page
  • Electrode Native APIs
  • Advantages of using APIs
  1. INTRODUCTION
  2. Overview

JS/Native communication

PreviousNative dependencies managementNextRequirements

Last updated 4 years ago

Because your MiniApps (written in JavaScript) are running inside a JavaScript virtual machine--they don't have direct access to your mobile application data and can't invoke methods in the mobile application. And your mobile application doesn't have direct access to your MiniApp code.

React Native offers constructs to communicate between the JavaScript side and the native side using its internal bridge-- mostly through native modules.

Electrode Native allows you to reuse existing React Native native modules and also comes with its own bridge.

The offers bi-directional communication constructs exposed as events and requests/response messages. Although the can be used directly in your mobile application or MiniApp to ease communication between the two sides, it is still a low level library. You will primarily use APIs, that are using the bridge under the hood, instead of interacting directly with it.

Electrode Native APIs

You can create and distribute your own Electrode Native APIs or re-use existing APIs.

While Electrode Native APIs are similar to React Native native modules (which you can also create -or reuse-) we don't recommend that you create new native modules if you plan on using Electrode Native. As a best practice, we recommend that you create APIs because of the advantages of using APIs over native modules in the Electrode Native workflow.

Advantages of using APIs

  • APIs are fully generated Just define the interactions your API should offer (as events and requests) in a Swagger schema, and the API code will be generated for JavaScript, iOS, and Android.

  • APIs also support the generation of model classes Just define your models in your Swagger schema and the necessary classes will be generated. Relying on the support means that on the mobile application side, developers are able to work with typed model classes and will be able to leverage compile time checks when dealing with APIs.

  • APIs decouple the client code of the API from its implementation You can implement the API on the native side or the JavaScript side. Because of this decoupling, it is also possible to write multiple implementations for a single API.

  • APIs are not native modules, they are clients of the which is the native module. There is no react native linking required for APIs.

  • APIs are generated and therefore will follow the exact same file system structure. This means that APIs don't need any customized configuration to be written for Electrode Native to properly add them to a container.

  • APIs are expected to follow a certain versioning convention, which offers more flexibility in terms of compatibility checks between different versions.

Electrode Native Bridge
Electrode Native Bridge
Electrode Native bridge
Electrode Native bridge