rezoner / playground

Playground.js is a framework for your javascript based games. It gives you out-of-box access to essentials like mouse, keyboard, sound and well designed architecture that you can expand to your needs.
MIT License
461 stars 50 forks source link

Add argument `context` into `Events.prototype.on` #8

Closed luizbills closed 9 years ago

luizbills commented 9 years ago

with a context argument you can use .call instead of .bind. Because .bind create a second function, consuming more memory.

rezoner commented 9 years ago

It's true that I've implemented events without context to gain speed - but then I am using bind which pretty much screws up the whole idea :)

PLAYGROUND.Events is nevertheless for internal usage - I will do a little benchmarking and think of implications. I kinda like bind and summed up it's probably consuming as much power as displaying a simple bitmap.

rezoner commented 9 years ago

Ok, I think you are right. I am reimplementing everything back to .call(context) :+1:

luizbills commented 9 years ago

:+1: