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
com.jasonelle.kernel.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 on page load.
-
Plugin.jscreates a "Click Me" button and appends 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.kthandle_call(callbackId:args:respond:), which responds by resolving the promise in the web view with{ status: 'ok' }.
Reference
-
com.jasonelle.kernel.Plugin– the base class this plugin extends. -
Plugin.jsinsrc/main/assets/plugins/hello/– the JavaScript client, byte-identical to the Xcode plugin.