diff --git a/404.html b/404.html index 4d9549009..3b951a79f 100644 --- a/404.html +++ b/404.html @@ -7,7 +7,7 @@ - + @@ -23,9 +23,9 @@
- - - + + + diff --git a/api/Task.html b/api/Task.html index 7841ffea3..6f153c3dc 100644 --- a/api/Task.html +++ b/api/Task.html @@ -1606,7 +1606,7 @@\n \n \n
',"joining-tasks.js":"import { task, timeout, all, race } from 'ember-concurrency';\nimport { tracked } from '@glimmer/tracking';\nconst methods = { all, race };\n\nexport default class JoiningTasksController extends Controller {\n @tracked childTasks = null;\n @tracked colors = ['#ff8888', '#88ff88', '#8888ff'];\n @tracked status = 'Waiting...';\n @tracked id = null;\n @tracked percent = null;\n\n parent = task({ restartable: true }, async (methodName) => {\n let allOrRace = methods[methodName];\n let childTasks = [];\n\n for (let id = 0; id < 5; ++id) {\n childTasks.push(this.child.perform(id));\n }\n\n this.childTasks = childTasks;\n this.status = 'Waiting for child tasks to complete...';\n let words = await allOrRace(childTasks);\n this.status = `Done: ${makeArray(words).join(', ')}`;\n });\n\n @task({ enqueue: true, maxConcurrency: 3 })\n child = {\n percent: 0,\n id: null,\n\n *perform(id) {\n this.id = id;\n while (this.percent < 100) {\n yield timeout(Math.random() * 100 + 100);\n let newPercent = Math.min(\n 100,\n Math.floor(this.percent + Math.random() * 20),\n );\n this.percent = newPercent;\n }\n return randomWord();\n },\n };\n}","last-value-decorator.js":"import Component from '@ember/component';\nimport { task } from 'ember-concurrency';\nimport { lastValue } from 'ember-concurrency';\n\nexport default class ExampleComponent extends Component {\n someTask = task(async () => {\n // ...\n });\n\n @lastValue('someTask')\n someTaskValue;\n\n @lastValue('someTask')\n someTaskValueWithDefault = 'A default value';\n}\n","loading-ui-controller.js":"export default class LoadingUIController extends Controller {\n @tracked result = null;\n\n askQuestion = dropTask(async () => {\n await timeout(1000);\n this.result = Math.random();\n });\n}","poll-loop-break-1.js":" pollForChanges = task(async () => {\n while(true) {\n await pollServerForChanges();\n if (Ember.testing) { return; }\n await timeout(5000);\n }\n })\n","poll-loop-classic.js":" async pollForChanges() {\n if (this.isDestroyed) { return; }\n await pollServerForChanges();\n run.later(this, 'pollForChanges', 5000);\n }\n","poll-loop.js":" pollForChanges = task(async () => {\n while(true) {\n yield pollServerForChanges();\n yield timeout(5000);\n }\n })\n","press-and-hold-buttons.hbs":"\n
\n \n \n
',"joining-tasks.js":"import { task, timeout, all, race } from 'ember-concurrency';\nimport { tracked } from '@glimmer/tracking';\nconst methods = { all, race };\n\nexport default class JoiningTasksController extends Controller {\n @tracked childTasks = null;\n @tracked colors = ['#ff8888', '#88ff88', '#8888ff'];\n @tracked status = 'Waiting...';\n @tracked id = null;\n @tracked percent = null;\n\n parent = task({ restartable: true }, async (methodName) => {\n let allOrRace = methods[methodName];\n let childTasks = [];\n\n for (let id = 0; id < 5; ++id) {\n childTasks.push(this.child.perform(id));\n }\n\n this.childTasks = childTasks;\n this.status = 'Waiting for child tasks to complete...';\n let words = await allOrRace(childTasks);\n this.status = `Done: ${makeArray(words).join(', ')}`;\n });\n\n @task({ enqueue: true, maxConcurrency: 3 })\n child = {\n percent: 0,\n id: null,\n\n *perform(id) {\n this.id = id;\n while (this.percent < 100) {\n yield timeout(Math.random() * 100 + 100);\n let newPercent = Math.min(\n 100,\n Math.floor(this.percent + Math.random() * 20),\n );\n this.percent = newPercent;\n }\n return randomWord();\n },\n };\n}","last-value-decorator.js":"import Component from '@ember/component';\nimport { task } from 'ember-concurrency';\nimport { lastValue } from 'ember-concurrency';\n\nexport default class ExampleComponent extends Component {\n someTask = task(async () => {\n // ...\n });\n\n @lastValue('someTask')\n someTaskValue;\n\n @lastValue('someTask')\n someTaskValueWithDefault = 'A default value';\n}\n","loading-ui-controller.js":"export default class LoadingUIController extends Controller {\n @tracked result = null;\n\n askQuestion = dropTask(async () => {\n await timeout(1000);\n this.result = Math.random();\n });\n}","poll-loop-break-1.js":" pollForChanges = task(async () => {\n while(true) {\n await pollServerForChanges();\n if (Ember.testing) { return; }\n await timeout(5000);\n }\n })\n","poll-loop-classic.js":" async pollForChanges() {\n if (this.isDestroyed) { return; }\n await pollServerForChanges();\n run.later(this, 'pollForChanges', 5000);\n }\n","poll-loop.js":" pollForChanges = task(async () => {\n while(true) {\n yield pollServerForChanges();\n yield timeout(5000);\n }\n })\n","press-and-hold-buttons.hbs":"\n
- Previous: Using maxConcurrency + Previous: Using maxConcurrency
- Next: Task Modifiers + Next: Task Modifiers
In the below example, we refactor the
- AJAX throttling example to use
+ AJAX throttling example to use
task events for logging of the ajaxTask
's state changes, instead
of doing it manually in the looping task itself.
- Previous: Using maxConcurrency + Previous: Using maxConcurrency
- Next: Task Modifiers + Next: Task Modifiers