Class
PluginGroup
View sourceExtendsPlugin
A Plugin that bundles several plugins into one app registration.
Add, remove, or replace members with the group methods, then register the
group with App#registerPlugin. The group is registered under its
own plugin ID; PluginGroup#register then forwards each contained
plugin to the app in map order. It inherits Plugin#finish,
Plugin#requires, and Plugin#name unless a subclass
overrides them.
Examples
import { App, Plugin, PluginGroup } from '@wimaengine/app'
class GameplayPlugin extends Plugin {}
class EnginePlugins extends PluginGroup {
constructor() {
super()
this.add(new GameplayPlugin())
}
}
const plugins = new EnginePlugins()
plugins.replace(new GameplayPlugin()) // change the member, keep one ID
new App()
.registerPlugin(plugins)
.setRunner(() => {})
.run()Constructor
Methods
add<T extends Plugin>(plugin: T): PluginGroup
View sourceAdds a plugin keyed by its Plugin#name type ID. If a plugin with
the same ID is already present, it is overwritten. Replacing an existing
map value with add does not move that ID to the end of iteration order;
use PluginGroup#replace when order should change.
remove(id: TypeId): PluginGroup
View sourceRemoves the plugin stored under a type ID. Missing IDs are ignored.
replace<T extends Plugin>(plugin: T): PluginGroup
View sourceReplaces the plugin with the same type ID by removing the current entry
and adding the supplied plugin. The replacement is therefore placed at the
end of map iteration order. If the ID was not present, this behaves like
PluginGroup#add.
register(app: App): void
View sourceRegisters each contained plugin with the app in map iteration order. The
app invokes this hook when the group itself is registered during
App#run. The contained plugins are registered through the app and
are processed by the app’s plugin registry after the current registration
pass reaches them; their normal Plugin#register and
Plugin#finish hooks are not called directly by the group.
