Setup formatting
This commit is contained in:
parent
d34f25295c
commit
dd850d11d1
45 changed files with 230 additions and 190 deletions
|
|
@ -3,5 +3,5 @@ import { CommandGenerator } from './command-generator';
|
|||
|
||||
export const broadcastCommands = (
|
||||
commandGenerators: Array<CommandGenerator>,
|
||||
commandReceivers: Array<CommandReceiver>
|
||||
commandReceivers: Array<CommandReceiver>,
|
||||
) => commandReceivers.forEach((r) => commandGenerators.forEach((g) => g.subscribe(r)));
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
import { Command } from './command';
|
||||
|
||||
export type CommandExecutors = {
|
||||
[type: string]: (command: Command) => void;
|
||||
[type: string]: (command: any) => unknown;
|
||||
};
|
||||
|
||||
export abstract class CommandReceiver {
|
||||
protected commandExecutors: CommandExecutors = {};
|
||||
|
||||
protected defaultCommandExecutor(command: Command) { }
|
||||
|
||||
public reactsToCommand(commandType: string): boolean {
|
||||
return Object.prototype.hasOwnProperty.call(this.commandExecutors, commandType);
|
||||
}
|
||||
|
||||
protected defaultCommandExecutor(_: Command) {}
|
||||
|
||||
public sendCommand(command: Command) {
|
||||
const commandType = command.type;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue