craftyjs/Crafty — pull request #500 by starwed (2013-06-30 21:14:24+00:00)
Title: Add unique and onetime binds

This adds two types of special binding methods. I don't like the current names, though! :)

* `. bindUnique()` prevents the same event from being bound more than once
* `.one()` removes the event once it is triggered

Just as we have `Crafty.bind()` and `entity.bind()`, there are two versions of these. I also added some basic qunit tests for binding/triggering them.

The current implementation is very straightforward (just exactly what I found myself doing in my own code) but could certainly be optimized.

***About the names***

* `.one()` is what jQuery uses for the same functionality, so I copied them. It's short, but I don't think it's a very intuitive name.
* `uniqueBind()` is ungainly, but at least describes what it does.

If you can come up with some better names, please let me know. :)