Once in a while you stumble across those tiny snippets of code
that ends up being a part of your project scaffolding.
I recently found one of these awesome snippets while browsing
github for cool projects.
Its name is MicroEvent and is a tiny observer type
It handles all your eventing for small projects and libraries,
and fits in very few lines of code:
I added the
.once() function since i use that a lot. I never had the need for an
but that would also be fairly easy to implement.
And you add the MicroEvent mixins to your prototype with
I think this is one of those pieces of code that makes you feel all warm and fuzzy inside. :)