mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-01 15:50:11 -04:00
Set up the supermodel to clear out jqxhrs once they're done, since they take a lot of memory.
This commit is contained in:
parent
bfa90f671d
commit
4b88296265
1 changed files with 9 additions and 0 deletions
|
@ -167,10 +167,12 @@ module.exports = class SuperModel extends Backbone.Model
|
|||
return unless @resources[r.rid]
|
||||
@num += r.value
|
||||
_.defer @updateProgress
|
||||
r.clean()
|
||||
|
||||
onResourceFailed: (source) ->
|
||||
return unless @resources[r.rid]
|
||||
@trigger('failed', source)
|
||||
r.clean()
|
||||
|
||||
updateProgress: =>
|
||||
# Because this is _.defer'd, this might end up getting called after
|
||||
|
@ -221,6 +223,10 @@ class Resource extends Backbone.Model
|
|||
markLoading: ->
|
||||
@isLoaded = @isFailed = false
|
||||
@isLoading = true
|
||||
|
||||
clean: ->
|
||||
# request objects get rather large. Clean them up after the request is finished.
|
||||
@jqxhr = null
|
||||
|
||||
load: -> @
|
||||
|
||||
|
@ -243,6 +249,9 @@ class ModelResource extends Resource
|
|||
@listenToOnce @model, 'sync', -> @markLoaded()
|
||||
@listenToOnce @model, 'error', -> @markFailed()
|
||||
|
||||
clean: ->
|
||||
@jqxhr = null
|
||||
@model.jqxhr = null
|
||||
|
||||
|
||||
class RequestResource extends Resource
|
||||
|
|
Loading…
Add table
Reference in a new issue