Plugins
Maycoon supports plugins to extend its capabilities. They must be specified at the Application
level using the plugins
method:
struct MyApp;
impl Application for MyApp {
type Theme = CelesteTheme;
type State = ();
fn build(_: AppContext, _: Self::State) -> impl Widget {
todo!("Your code")
}
fn config(&self) -> MayConfig<Self::Theme> {
todo!("Your code")
}
fn plugins(&self) -> PluginManager<Self::Theme> {
let mut plugins = PluginManager::new();
plugins.register(MyPlugin);
plugins
}
}
Plugins are not only used to extend the framework, but also directly manipulate the internal state of the application.
A simple plugin may look like this:
pub struct MyPlugin;
impl<T: Theme> Plugin<T> for MyPlugin {
fn name(&self) -> &'static str {
"my_plugin"
}
fn on_register(&mut self, _manager: &mut PluginManager<T>) {
println!("Hello World!");
}
fn on_unregister(&mut self, _manager: &mut PluginManager<T>) {
println!("Bye World!");
}
}
See the plugin example for full usage.