Expand description
A formal plugin API for AppFront applications (Phase 4 / #47).
A Plugin is a self-contained unit of cross-cutting functionality that an
app registers at startup. It has a typed state S (shared via the existing
Context mechanism) and a set of hooks that
run at well-defined points in the app lifecycle: before/after the tree is
built, and around each render. This gives apps an extension point without
baking backend-specific fields into UITree.
ⓘ
struct Analytics;
impl Plugin for Analytics {
type State = ();
fn on_render(&self, _: &PluginCtx<Self::State>) {
// ... count renders ...
}
}
let mut registry = PluginRegistry::new();
registry.register(Analytics);
registry.run_render_hooks();The API is backend-agnostic: a plugin only ever sees lifecycle events and the shared app state, never a DOM/canvas/TUI handle, so the same plugin works on every backend.
Structs§
- Plugin
Ctx - A plugin’s read-only view of app + plugin state during a hook.
- Plugin
Registry - Holds every registered
Pluginand runs their hooks at the right times.
Traits§
- Plugin
- A plugin: a named, self-contained extension with typed state.
Functions§
- context_
for_ plugin - Convenience: provides a plugin’s state to a subtree as a
Contextso descendant components can read it.