class Dispatcher { constructor() { this.commands = {}; } AddCommand(command_name, command) { this.commands[command_name] = command; } Dispatch(response) { if (response["status"] != "ok") { alert(`Возникла ошибка. Пожалуйста, сообщите о ней разработчикам: ${response["error_message"]}`); return; } let command = response["command"]; console.log("dispatching " + command); this.commands[command].ProcessResponse(response); } commands; }