mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Reached a steady state without bower component backbone mediator
This commit is contained in:
parent
fc8684967d
commit
f94dfeae6d
2 changed files with 26 additions and 21 deletions
|
@ -2,16 +2,16 @@ app = require 'application'
|
|||
|
||||
channelSchemas =
|
||||
'app': require './schemas/subscriptions/app'
|
||||
'bus': require './schemas/subscriptions/bus'
|
||||
'editor': require './schemas/subscriptions/editor'
|
||||
'errors': require './schemas/subscriptions/errors'
|
||||
'level': require './schemas/subscriptions/level'
|
||||
'misc': require './schemas/subscriptions/misc'
|
||||
'play': require './schemas/subscriptions/play'
|
||||
'surface': require './schemas/subscriptions/surface'
|
||||
'tome': require './schemas/subscriptions/tome'
|
||||
'user': require './schemas/subscriptions/user'
|
||||
'world': require './schemas/subscriptions/world'
|
||||
#'bus': require './schemas/subscriptions/bus'
|
||||
#'editor': require './schemas/subscriptions/editor'
|
||||
#'errors': require './schemas/subscriptions/errors'
|
||||
#'level': require './schemas/subscriptions/level'
|
||||
#'misc': require './schemas/subscriptions/misc'
|
||||
#'play': require './schemas/subscriptions/play'
|
||||
#'surface': require './schemas/subscriptions/surface'
|
||||
#'tome': require './schemas/subscriptions/tome'
|
||||
#'user': require './schemas/subscriptions/user'
|
||||
#'world': require './schemas/subscriptions/world'
|
||||
|
||||
definitionSchemas =
|
||||
'bus': require './schemas/definitions/bus'
|
||||
|
@ -27,8 +27,8 @@ init = ->
|
|||
filepicker.setKey('AvlkNoldcTOU4PvKi2Xm7z')
|
||||
|
||||
# Set up Backbone.Mediator schemas
|
||||
configureChannels()
|
||||
configureDefinitions()
|
||||
setUpDefinitions()
|
||||
setUpChannels()
|
||||
|
||||
$ -> init()
|
||||
|
||||
|
@ -53,10 +53,10 @@ handleNormalUrls = ->
|
|||
|
||||
return false
|
||||
|
||||
configureChannels = ->
|
||||
setUpChannels = ->
|
||||
for channel of channelSchemas
|
||||
Backbone.Mediator.addChannelSchemas channelSchemas[channel]
|
||||
|
||||
configureDefinitions = ->
|
||||
setUpDefinitions = ->
|
||||
for definition of definitionSchemas
|
||||
Backbone.Mediator.addDefSchemas definitionSchemas[definition]
|
19
vendor/scripts/backbone-mediator.js
vendored
19
vendor/scripts/backbone-mediator.js
vendored
|
@ -106,14 +106,19 @@
|
|||
publish: function (channel, arg) {
|
||||
if (!channels[channel]) return;
|
||||
|
||||
if (channel in this.channelSchemas && this.validationEnabled) {
|
||||
var valid = this.tv4.validate(arg, this.channelSchemas[channel]);
|
||||
if (!valid) {
|
||||
console.error("Dropping publication because of validation error:", this.tv4.error);
|
||||
return;
|
||||
} else if (this.tv4.missing.length) {
|
||||
console.warn("Missing schema reference to " + this.tv4.missing[0]);
|
||||
if (channel in this.defSchemas) {
|
||||
if (this.validationEnabled) {
|
||||
var valid = this.tv4.validate(arg, this.channelSchemas[channel]);
|
||||
if (!valid) {
|
||||
console.error("Dropping publication because of validation error:", this.tv4.error);
|
||||
return;
|
||||
} else if (this.tv4.missing.length) {
|
||||
console.warn("Missing schema reference to " + this.tv4.missing[0]);
|
||||
}
|
||||
}
|
||||
} else if (!_.contains(this.unvalidatedChannels, channel)) {
|
||||
this.unvalidatedChannels.push(channel);
|
||||
console.warn("Missing schema for channel '" + channel + "'.");
|
||||
}
|
||||
|
||||
var subscription;
|
||||
|
|
Loading…
Reference in a new issue