Skip to content

Instantly share code, notes, and snippets.

@aslushnikov
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save aslushnikov/85b478150577d5772b3d to your computer and use it in GitHub Desktop.

Select an option

Save aslushnikov/85b478150577d5772b3d to your computer and use it in GitHub Desktop.
function FullTask()
{
this._downloadTask = new DownloadTask();
this._processTask = new ProcessTask();
this._renderTask = new RenderTask();
this._progress = new ProgressModel();
this._progress.setTotal(this._downloadTask.progress().total() * 8 +
this._processTask.progress().total() +
this._renderTask.progress().total());
this._downloadTask.progress().addEventListener(WorkChanged, this._onWorkChanged.bind(this));
this._processTask.progress().addEventListener(WorkChanged, this._onWorkChanged.bind(this));
this._renderTask.progress().addEventListener(WorkChanged, this._onWorkChanged.bind(this));
this._progress.addEventListener(Cancelled, this._onCancelled.bind(this));
this._renderTask.progress().addEventListener(WorkDone, this._onDone.bind(this));
}
FullTask.prototype = {
/**
* @return {!ProgressInterface}
*/
progress: function()
{
return this._progress;
},
_onWorkChanged: function(event)
{
this._progress.setWorked(this._downloadTask.progress().worked() * 8 +
this._processTask.progress().worked() +
this._renderTask.progress().worked());
},
_onCancelled: function(event)
{
this._downloadTask.progress().cancel();
this._processTask.progress().cancel();
this._renderTask.progress().cancel();
},
_onDone: function(event)
{
this._progress.done();
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment