this.loading = false;
},
hasLoadedOnce: function() {
return this.loadedOnce;
},
isLoading: function() {
return this.loading;
},
getLoadedOncePromise: function() {
return this.loadedOnceDeferred.promise();
},
fetch: function(options) {
return this.__loadWrapper(base.prototype.fetch, options);
},
__loadWrapper: function(fetchMethod, options) {
var object = this;
this.loadingCount++;
this.loading = true;
this.trigger('load-begin');
return $.when(fetchMethod.call(object, options)).always(function() {
if (!object.loadedOnce) {
object.loadedOnce = true;
object.loadedOnceDeferred.resolve();
}
object.loadingCount--;
if (object.loadingCount <= 0) {
object.loadingCount = 0;
object.loading = false;
}
}).done(function(data, textStatus, jqXHR) {
object.trigger('load-complete', {success: true, data: data, textStatus: textStatus, jqXHR: jqXHR});
}).fail(function(jqXHR, textStatus, errorThrown) {
object.trigger('load-complete', {success: false, jqXHR: jqXHR, textStatus: textStatus, errorThrown: errorThrown});
});
}
};
};
return loadingMixin;
}));