Setup formatting

This commit is contained in:
schmelczerandras 2020-10-07 16:40:21 +02:00
parent d34f25295c
commit dd850d11d1
45 changed files with 230 additions and 190 deletions

View file

@ -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)));

View file

@ -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;