Class
CommandsPlugin
View sourceExtendsPlugin
Adds deferred command execution to an App.
CommandsPlugin provides a CommandQueue resource in the app’s
default world. Add Command instances to the queue when a world
mutation should be applied later. Queued commands execute in FIFO order
during app execution; commands added after a batch begins wait for the next
batch.
CommandsPlugin requires CorePlugin. Register it before
App#run; the app validates the dependency but does not install it
automatically.
Examples
import { App } from '@wimaengine/app'
import { Command, CommandQueue, CommandsPlugin } from '@wimaengine/command'
import { CorePlugin } from '@wimaengine/core'
import { ReflectPlugin } from '@wimaengine/reflect'
class PrintCommand extends Command {
execute(_world) {
console.log('command executed')
}
}
const app = new App()
.registerPlugin(new ReflectPlugin())
.registerPlugin(new CorePlugin())
.registerPlugin(new CommandsPlugin())
app.run()
app.getWorld().getResource(CommandQueue).add(new PrintCommand())Constructor
Methods
register(app: App): void
View sourceAdds a CommandQueue to the app’s default world and enables
deferred commands to be applied during app execution.
Commands already queued when a processing pass begins execute in FIFO order. Commands added during that pass remain queued for the next pass.
requires(): TypeId[]
View sourceDeclares the core plugin required by this plugin.
The app validates this dependency after plugin registration and does not
install it automatically. A missing CorePlugin causes
App#run to throw.
