mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-26 22:13:32 -04:00
Migrate from .on, .once to .listenTo, .listenToOnce
This commit is contained in:
parent
5852b87aa3
commit
1118324b41
5 changed files with 13 additions and 13 deletions
app
lib
models
views
account
editor/thang
play/level/modal
|
@ -60,13 +60,13 @@ module.exports = class LevelLoader extends CocoClass
|
|||
# Unless you specify cache:false, sometimes the browser will use a cached session
|
||||
# and players will 'lose' code
|
||||
@session.fetch({cache:false})
|
||||
@session.once 'sync', @onSessionLoaded, @
|
||||
@listenToOnce(@session, 'sync', @onSessionLoaded)
|
||||
|
||||
if @opponentSessionID
|
||||
@opponentSession = new LevelSession()
|
||||
@opponentSession.url = "/db/level_session/#{@opponentSessionID}"
|
||||
@opponentSession.fetch()
|
||||
@opponentSession.once 'sync', @onSessionLoaded, @
|
||||
@listenToOnce(@opponentSession, 'sync', @onSessionLoaded)
|
||||
|
||||
sessionsLoaded: ->
|
||||
return true if @headless
|
||||
|
@ -82,8 +82,8 @@ module.exports = class LevelLoader extends CocoClass
|
|||
# Supermodel (Level) Loading
|
||||
|
||||
loadLevelModels: ->
|
||||
@supermodel.on 'loaded-one', @onSupermodelLoadedOne, @
|
||||
@supermodel.once 'error', @onSupermodelError, @
|
||||
@listenTo(@supermodel, 'loaded-one', @onSupermodelLoadedOne)
|
||||
@listenToOnce(@supermodel, 'error', @onSupermodelError)
|
||||
@level = @supermodel.getModel(Level, @levelID) or new Level _id: @levelID
|
||||
levelID = @levelID
|
||||
headless = @headless
|
||||
|
|
|
@ -9,8 +9,8 @@ class SuperModel
|
|||
@mustPopulate = model
|
||||
model.saveBackups = @shouldSaveBackups(model)
|
||||
model.fetch() unless model.loaded or model.loading
|
||||
model.once('sync', @modelLoaded, @) unless model.loaded
|
||||
model.once('error', @modelErrored, @) unless model.loaded
|
||||
@listenTo(model, 'sync', @modelLoaded) unless model.loaded
|
||||
@listenToOnce(model, 'error', @modelErrored) unless model.loaded
|
||||
url = model.url()
|
||||
@models[url] = model unless @models[url]?
|
||||
@modelLoaded(model) if model.loaded
|
||||
|
@ -30,7 +30,7 @@ class SuperModel
|
|||
schema = model.schema()
|
||||
unless schema.loaded
|
||||
@schemas[schema.urlRoot] = schema
|
||||
return schema.once('sync', => @modelLoaded(model))
|
||||
return @listenToOnce(schema, 'sync', -> @modelLoaded(model))
|
||||
refs = model.getReferencedModels(model.attributes, schema.attributes, '/', @shouldLoadProjection)
|
||||
refs = [] unless @mustPopulate is model or @shouldPopulate(model)
|
||||
# console.log 'Loaded', model.get('name')
|
||||
|
@ -40,7 +40,7 @@ class SuperModel
|
|||
continue if @models[refURL]
|
||||
@models[refURL] = ref
|
||||
ref.fetch()
|
||||
ref.once 'sync', @modelLoaded, @
|
||||
@listenToOnce(ref, 'sync', @modelLoaded)
|
||||
|
||||
@trigger 'loaded-one', model: model
|
||||
@trigger 'loaded-all' if @finished()
|
||||
|
|
|
@ -24,7 +24,7 @@ module.exports = class WizardSettingsView extends CocoView
|
|||
@wizardThangType = new ThangType()
|
||||
@wizardThangType.url = -> '/db/thang.type/wizard'
|
||||
@wizardThangType.fetch()
|
||||
@wizardThangType.once 'sync', @initCanvas, @
|
||||
@listenToOnce(@wizardThangType, 'sync', @initCanvas)
|
||||
|
||||
initCanvas: ->
|
||||
@startsLoading = false
|
||||
|
|
|
@ -11,8 +11,8 @@ module.exports = class ColorsTabView extends CocoView
|
|||
offset: 0
|
||||
|
||||
constructor: (@thangType, options) ->
|
||||
@thangType.once 'sync', @tryToBuild, @
|
||||
@thangType.schema().once 'sync', @tryToBuild, @
|
||||
@listenToOnce(@thangType, 'sync', @tryToBuild)
|
||||
@listenToOnce(@thangType.schema(), 'sync', @tryToBuild)
|
||||
@colorConfig = { hue: 0, saturation: 0.5, lightness: 0.5 }
|
||||
@spriteBuilder = new SpriteBuilder(@thangType)
|
||||
f = =>
|
||||
|
|
|
@ -38,8 +38,8 @@ module.exports = class VictoryModal extends View
|
|||
@feedback = new LevelFeedback()
|
||||
@feedback.url = -> url
|
||||
@feedback.fetch()
|
||||
@feedback.once 'sync', => @onFeedbackLoaded()
|
||||
@feedback.once 'error', => @onFeedbackNotFound()
|
||||
@listenToOnce(@feedback, 'sync', -> @onFeedbackLoaded())
|
||||
@listenToOnce(@feedback, 'error', -> @onFeedbackNotFound())
|
||||
|
||||
onFeedbackLoaded: ->
|
||||
@feedback.url = -> '/db/level.feedback/' + @id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue