1.15.1 • Published 5 years ago
webiny-plugins v1.15.1
webiny-plugins
A simple registry that stores all plugins in a shared object.
The only requirement for a plugin is to have a name
and a type
properties.
The rest is entirely up to you.
There is nothing spectacular going on under the hood, just a simple object for storing references and a few utility functions.
For more information, please visit the official docs.
Install
npm install --save webiny-plugins
Or if you prefer yarn:
yarn add webiny-plugins
Usage
Adding a plugin
import { registerPlugins } from "webiny-plugins";
// Add a plugin
registerPlugins({
name: "my-plugin",
type: "say-hi",
salute: () => "Hi!"
});
registerPlugins({
name: "my-second-plugin",
type: "say-hi",
salute: () => "Yo!"
});
Getting plugins by type
// anywhere in your app
import { getPlugins } from "webiny-plugins";
const plugins = getPlugins("say-hi");
plugins.forEach(plugin => {
// Call "salute" function
plugin.salute();
});
Getting a single plugin by name
// anywhere in your app
import { getPlugin } from "webiny-plugins";
const plugin = getPlugin("my-plugin");
// Call "salute" function
plugin.salute();
Removing a plugin
// anywhere in your app
import { unregisterPlugin } from "webiny-plugins";
unregisterPlugin("my-plugin");
1.15.1
5 years ago
1.15.0
5 years ago
1.14.2
6 years ago
1.14.1
6 years ago
1.14.0
6 years ago
1.13.1
6 years ago
1.13.0
6 years ago
1.12.7
6 years ago
1.12.6
6 years ago
1.12.5
6 years ago
1.12.4
6 years ago
1.12.3
6 years ago
1.12.2
6 years ago
1.12.1
6 years ago
1.12.0
6 years ago
1.11.0
6 years ago
1.10.5
6 years ago
1.10.4
6 years ago
1.10.3
6 years ago
1.10.2
6 years ago
1.10.1
6 years ago
1.10.0
6 years ago
1.9.0
6 years ago
1.8.1
6 years ago
1.8.0
6 years ago
1.7.0
6 years ago
1.6.0
6 years ago
1.5.1
6 years ago
1.5.0
6 years ago