PluginGroup

View source

ExtendsPlugin

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


constructor()

Methods


add<T extends Plugin>(plugin: T): PluginGroup

View source

Adds 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.

Type Parameters

T extends Plugin

Parameters

NameDescriptionDefault
plugin——

remove(id: TypeId): PluginGroup

View source

Removes the plugin stored under a type ID. Missing IDs are ignored.

Parameters

NameDescriptionDefault
id——

replace<T extends Plugin>(plugin: T): PluginGroup

View source

Replaces 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.

Type Parameters

T extends Plugin

Parameters

NameDescriptionDefault
plugin——

register(app: App): void

View source

Registers 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.

Parameters

NameDescriptionDefault
app——