ember-resources
does not provide or depend on ember-concurrency.
If you want to use task, you'll need to add ember-concurrency as a dependency
in your project.
When this.id
changes, the task will automatically be re-invoked.
import { tracked } from '@glimmer/tracking';
import { restartableTask, timeout } from 'ember-concurrency';
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
class Demo {
@tracked id = 1;
searchTask = restartableTask(async () => {
await timeout(200);
await fetch('...');
return 'the-value';
})
last = trackedTask(this, this.searchTask, () => [this.id]);
}
Available Properties:
{{this.last.value}}
{{this.last.isFinished}}
{{this.last.isRunning}}
(and all other properties on a TaskInstance)
uses Resource to make ember-concurrency tasks reactive.