Skip to main content

Class: Command<S>

Type parameters

NameType
Sextends State = State

Hierarchy

Implements

Constructors

constructor

new Command<S>(name?)

Type parameters

NameType
Sextends State<Record<string, unknown>, S> = State<Record<string, unknown>>

Parameters

NameTypeDescription
name?stringprovide only if you're using new Command() syntax. If you're extending command, just leave it empty - the name will be grabbed from class name.

Accessors

name

get name(): string

Returns

string

Methods

execute

execute(state, room): Promise<void>

Parameters

NameType
stateS
roomRoom<S, Record<string, unknown>>

Returns

Promise<void>

Implementation of

ICommand.execute


subExecute

Protected subExecute(state, room, command): Promise<void>

Execute a sub command. Call ONLY during your commands execute method. Will also remember it internally for undoing.

Parameters

NameType
stateS
roomRoom<S, Record<string, unknown>>
commandCommand<S>

Returns

Promise<void>


undo

undo(state, room): Promise<void>

Undoes every remembered extra sub command. Command may gather new sub commands only while executing. Sequence will only gather sub commands upon construction.

Parameters

NameType
stateS
roomRoom<any, Record<string, unknown>>

Returns

Promise<void>

Implementation of

ICommand.undo