7
Машинопис "this" всередині методу класу
Я знаю, що це, мабуть, болісно базово, але мені важко обмотати це головою. class Main { constructor() { requestAnimationFrame(this.update); //fine } update(): void { requestAnimationFrame(this.update); //error, because this is window } } Схоже, мені потрібен проксі, тож скажімо, використовуючи Jquery class Main { constructor() { this.updateProxy = $.proxy(this.update, this); requestAnimationFrame(this.updateProxy); …