Recently, I developed a basic 2D-tile-renderer using JavaScript and decided to convert it to TypeScript. The process went smoothly, with the only challenge being when I tried to call window.requestAnimationFrame with a callback function.
Eventually, I was able to get it working correctly, but I noticed that my implementation deviated from typical TypeScript practices:
// ... some initialization code above
var mapper = this;
(function animloop() {
window.requestAnimationFrame(animloop);
mapper.draw();
})();
To avoid using 'this' within the anonymous function, I had to store it in an auxiliary variable.
I attempted to utilize a TypeScript lambda ( => ), but ran into difficulties understanding the parameter required by the requestAnimationFrame method.
Do you have any recommendations or suggestions for improving my approach?