A plugin groups multiple hooks in a same place. As such, it must exports at least one hook inside the hooks
property.
A plugin is an object literal with the properties:
hooks
({name: hook})
List of hooks identified by hook names.name
(string)
Name of the plugin.require
([string])
Names of the required plugins.
Alternatively, a plugin can be defined as a function which returns the same plugin object and receive the args
property from the Plug-And-Play function.
Plug and Play can be initialized with a list of plugins through the plugins
options:
import { plugandplay } from 'plug-and-play'
plugandplay({
plugins: [{
hooks: {
'my:hook': () => { console.log('"my:hook" is called') }
}
}]
})
Or later on with the register
function:
import { plugandplay } from 'plug-and-play'
plugandplay()
.register({
hooks: {
'my:hook': () => { console.log('"my:hook" is called') }
}
})