alaingilbert/Turntable-API — pull request #232 by gizmotronic (2013-07-01 00:47:14+00:00)
Title: Use WebSocket events instead of callbacks

I've been testing [event handlers vs. callbacks](https://gist.github.com/gizmotronic/5893457) using code structured in the same way that our WebSocket class:

```js
self.emit('something', data);
if (self.onsomething) {
self.onsomething(data);
}
```

Before my testing I would have thought that callbacks were more efficient. They're simpler creatures without the overhead of yet another object. And, after all, the event handler is provided a callback to do the work, right? Handling events is significantly more efficient as it turns out. In some cases it's radically so.

I invite you to run my test script, make it a more accurate representation, and otherwise show how it doesn't say what I'm claiming. If you are seeing the same advantage, though, I think this is a worthy change without any impact to the API.