/** * A Task is a cancelable, restartable, asynchronous operation that * is driven by an async function. Tasks are automatically canceled * when the object they live on is destroyed (e.g. a Component * is unrendered). * * To define a task, use the `task(...)` function, and pass in * an async arrow function, which will be invoked when the task * is performed. Async functions with the await keyword can * be used to elegantly express asynchronous, cancelable * operations. * * The following Component defines a task called `myTask` that, * when performed, prints a message to the console, sleeps for 1 second, * prints a final message to the console, and then completes. * * ```js * import Component from '@glimmer/component'; * import { task, timeout } from 'ember-concurrency'; * * export default class MyComponent extends Component { * myTask = task(async () => { * console.log("Pausing for a second..."); * await timeout(1000); * console.log("Done!"); * }); * } * ``` * * ```hbs * * ``` * * By default, tasks have no concurrency constraints * (multiple instances of a task can be running at the same time) * but much of a power of tasks lies in proper usage of Task Modifiers * that you can apply to a task. * * @param {function} taskFunction the async function backing the task. * @returns {TaskProperty} */ export function task(...args: any[]): TaskProperty; //# sourceMappingURL=task-public-api.d.ts.map