0.0.2 • Published 4 years ago

@esun/plugin-utils v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

Install

npm install --save @esun/plugin-utils

Or if you prefer yarn:

yarn add @esun/plugin-utils

Usage

Adding a plugin

import { registerPlugins } from "@esun/plugin-utils";

// Add a plugin
registerPlugins({
    name: "my-plugin-demo",
    type: "basic-demo",
    render: () => "Hi!"
});

registerPlugins({
    name: "my-plugin-demo2",
    type: "basic-demo",
    render: () => "Hello!"
});

Getting a single plugin by name

// anywhere in your app
import { getPlugin } from "@esun/plugin-utils";

const plugin = getPlugin("my-plugin-demo");
plugin.render();

Getting plugins by type

// anywhere in your app
import { getPlugins } from "@esun/plugin-utils";

const plugins = getPlugins("basic-demo");
<!-- const plugins = getPlugins(); get all plugins-->
plugins.forEach(plugin => {
    plugin.render();
});

Removing a plugin

// anywhere in your app
import { unregisterPlugin } from "@esun/plugin-utils";

unregisterPlugin("my-plugin-demo");