H5Service
, H5Session
and H5Page
are the fundamental components in Nebula, please click here for more details.
The Nebula JS Bridge is the interpretation broker between native layer and Javascript code, it translates the Javascript code into native byte code to be executed in platform framework, and also converts native data structure into Javascript object so they can be processed in Javascript layer.
There are many JS Bridge implementations out in the market, most of them are based on prompt
interception, whereas Nebula uses console.log
API instead. There are two drawbacks of prompt
approach
prompt
is a blocking API, the page will not be responding if native code execution takes too much timeprompt
actually creates a modal window if the native webview does not intercept it. So if the JS code is called before JS bridge is initialized, the interception would not be executed and thus a modal window will be displayed and confuses the userThe event dispatcher propagates event from service to pages, please refer here for detailed information.
Nebula has already shipped lots of JS API for you to manipulate the UI, communicate with RCP service or even prompt dialog or toast. Please click here for more information about JS API.
If there is no existing JS API that meet your requirement, you can create a new plugin, put the native implementation code inside, register it to the Plugin manager, and invoke it via your custom JS API. please find more about customization here.