Skip to content

Instantly share code, notes, and snippets.

@jmuzsik
Created July 30, 2019 04:10
Show Gist options
  • Save jmuzsik/62430898767ccf760220f8ed8852be56 to your computer and use it in GitHub Desktop.
Save jmuzsik/62430898767ccf760220f8ed8852be56 to your computer and use it in GitHub Desktop.
startBackgroundTasks() {
console.info('Background Tasks have begun.');
// Subtlety: Data is reset if start is clicked multiple times repeated clicks.
this.totalTaskCount = 0;
this.currentTaskNumber = 0;
this.updateDisplay();
// Create a bunch of tasks.
const n = this.getRandomIntInclusive(200, 400);
for (let i = 0; i < n; i++) {
const taskData = {
// The amount of elements that will be created in this task.
count: this.getRandomIntInclusive(150, 300),
// The text that will be rendered in the element.
text: `This text is from task number ${(i + 1).toString()} of ${n}`
};
this.enqueueTask(this.logTaskHandler, taskData);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment