I would put all your deferreds in an array, (they remove themselves when the request completes). Overwrite the destroy method to .abort() all remaining requests in that array.
doSomething: function(){
this.request( Todo.findAll({}, $.proxy(this.showTodos) ) )
},
request: function(deferred){
var requests = this._requests || (this._requests = [] )
requests.push(deferred)
requests.push(deferred)
deferred.always(function(){
requests.splice(requests.indexOf(deferrred),1)
})
return deferred;
return deferred;
}
destroy: function(){
can.each(this._requests || [], function(def){
def.abort()
})
return can.Control.prototype.destroy.apply(this, arguments)
}
destroy: function(){
can.each(this._requests || [], function(def){
def.abort()
})
return can.Control.prototype.destroy.apply(this, arguments)
}