import { TaskInstance } from 'ember-concurrency'; /** * A task can be used instead of a promise in some cases, but a task * has the advantage of being cancellable. See ember-concurrency. */ export type PromiseOrTask = PromiseLike | TaskInstance | undefined; /** * Will check if the type is a promise or a task. The difference is that * a task is cancellable where as a promise not (for now). * @param obj the object to check */ export function isTask(obj: PromiseOrTask): obj is TaskInstance { return typeof obj !== 'undefined' && (>obj).cancel !== undefined; }