codecombat/codecombat — pull request #740 by rubenvereecken (2014-03-30 11:53:40+00:00)
Title: Validated Backbone Mediator (with schemas)

I forked the currently existing Backbone Mediator: [Validated Backbone Mediator](https://github.com/rubenvereecken/Validated-Backbone-Mediator) is now a thing. I wasn't too sure whether I should create a pull request or issue for this, but I wanted to throw out there what I've already got concerning the integration of the new mediator into CodeCombat.

The goal (issue #40): Have objects that get sent around for subscriptions follow schemas. This allows for documentation of what's flying around and easier debugging.

What have we already got? A new Mediator that checks all objects it's supposed to publish against the schemas it's been provided with. This setup happens in `initialize.coffee`. All schemas reside in `schemas`. Schemas should be classified somewhat. To this purpose I've created an example `bus.coffee` (holding all bus related stuff) and `misc.coffee` (currently holding jQueryEvent). There are two kinds of schemas: schemas describing an object that goes through a channel and definition schemas that other schemas can refer to (more on this at the official json-schema docs). They serve as a core repository. To add to this, all model schemas should move to `app/schemas` as well but I haven't yet performed this refactoring.

I don't have too much spare time on my hands for the following days, but I'll focus on supplying barebone files and definitions that other developers can add to. Together this should be a quick job, and an easy one at that.

Any feedback would be greatly appreciated!