pub trait Plugin<R: Runtime>: Send {
// Required method
fn name(&self) -> &'static str;
// Provided methods
fn initialize(
&mut self,
app: &AppHandle<R>,
config: JsonValue
) -> Result<()> { ... }
fn initialization_script(&self) -> Option<String> { ... }
fn created(&mut self, window: Window<R>) { ... }
fn on_page_load(&mut self, window: Window<R>, payload: PageLoadPayload) { ... }
fn on_event(&mut self, app: &AppHandle<R>, event: &RunEvent) { ... }
fn extend_api(&mut self, invoke: Invoke<R>) { ... }
}
Expand description
The plugin interface.
Required Methods§
Provided Methods§
sourcefn initialize(&mut self, app: &AppHandle<R>, config: JsonValue) -> Result<()>
fn initialize(&mut self, app: &AppHandle<R>, config: JsonValue) -> Result<()>
Initializes the plugin.
sourcefn initialization_script(&self) -> Option<String>
fn initialization_script(&self) -> Option<String>
Add the provided JavaScript to a list of scripts that should be run after the global object has been created, but before the HTML document has been parsed and before any other script included by the HTML document is run.
Since it runs on all top-level document and child frame page navigations,
it’s recommended to check the window.location
to guard your script from running on unexpected origins.
The script is wrapped into its own context with (function () { /* your script here */ })();
,
so global variables must be assigned to window
instead of implicitly declared.
sourcefn on_page_load(&mut self, window: Window<R>, payload: PageLoadPayload)
fn on_page_load(&mut self, window: Window<R>, payload: PageLoadPayload)
Callback invoked when the webview performs a navigation to a page.
sourcefn on_event(&mut self, app: &AppHandle<R>, event: &RunEvent)
fn on_event(&mut self, app: &AppHandle<R>, event: &RunEvent)
Callback invoked when the event loop receives a new event.
sourcefn extend_api(&mut self, invoke: Invoke<R>)
fn extend_api(&mut self, invoke: Invoke<R>)
Extend commands to crate::Builder::invoke_handler
.