#
Register plugins
To keep Squide lightweight, not all functionalities should be integrated as a core functionality. However, to accommodate a broad range of technologies, a plugin system has been implemented to fill the gap.
#
Register a plugin
Plugins can be registered at bootstrapping with the initializeFirefly function:
import { initializeFirefly } from "@squide/firefly";
import { MyPlugin } from "@sample/my-plugin";
const runtime = initializeFirefly({
plugins: [x => new MyPlugin(x)]
});
#
Retrieve a plugin
Using the usePlugin hook:
import { usePlugin } from "@squide/firefly";
import { MyPlugin } from "@sample/my-plugin";
const myPlugin = usePlugin(MyPlugin.name) as MyPlugin;
Using the runtime instance:
import { MyPlugin } from "@sample/my-plugin";
// If the plugin isn't registered, an error is thrown.
const plugin = runtime.getPlugin(MyPlugin.name) as MyPlugin;