1.15.1 • Published 5 years ago

webiny-plugins v1.15.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

webiny-plugins

npm.io npm.io code style: prettier PRs Welcome

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

5 years ago

1.14.1

5 years ago

1.14.0

5 years ago

1.13.1

5 years ago

1.13.0

5 years ago

1.12.7

5 years ago

1.12.6

5 years ago

1.12.5

5 years ago

1.12.4

5 years ago

1.12.3

5 years ago

1.12.2

5 years ago

1.12.1

5 years ago

1.12.0

5 years ago

1.11.0

5 years ago

1.10.5

5 years ago

1.10.4

5 years ago

1.10.3

5 years ago

1.10.2

5 years ago

1.10.1

5 years ago

1.10.0

5 years ago

1.9.0

5 years ago

1.8.1

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago