Trying to create a timer loop in TypeScript:
timeout() {
setTimeout(function () {
console.log('Test');
this.timeout();
}, 1000/60);
}
But after the first loop works correctly I'm getting this error: "Uncaught TypeError: this.timeout is not a function". It seems that the this variable does not exist after the initial loop. Any ideas?
=>) instead offunctionthen thethiscontext will be captured inside the nested function automatically. Useful docs: basarat.gitbooks.io/typescript/content/docs/… and typescriptlang.org/docs/handbook/functions.html