JLPluginHello
A sample Jasonelle plugin that demonstrates the native–JavaScript bridge.
Overview
JLPluginHello is the simplest working plugin for Jasonelle. It shows how to:
-
Subclass
Pluginand override its native handler. -
Register a JavaScript object on
window.jasonelle.plugins.*. -
Call native code from JavaScript and receive a response back in the web view.
Structure
| File | Role |
|---|---|
|
Native side – handles calls from JavaScript. |
|
JavaScript side – registers the plugin, injects a button, and calls the native handler. |
How it works
-
The plugin is injected into the web view at document end.
-
Plugin.jscreates a "Click Me" button and prepends it to the DOM. -
Clicking the button calls
window.jasonelle.plugins.hello.call("Hello", "World"), which returns a promise. -
The call is routed to
Plugin.swiftcall(args:callbackId:respond:), which responds by resolving the promise in the web view with{ status: 'ok' }.