task resolve type
Invoke underlying cancel method without error
'true' when the task was still pending and cancelation was applied
Wrap task to singleton generator
Userful in order to avoid ambiguous yied types
const getString = () => Task.resolved('hello');
const getLength = (data: string) => Task.resolved(data.length);
// ..... //
Task.generate(function* () {
const data = yield getString(); // data: string | number
const length = yield getLength(data); // length: string | number
return length;
});
// ..... //
Task.generate(function* () {
const data = yield* getString().generator(); // data: string
const length = yield* getLength(data).generator(); // length: number
return length;
});
Invoke underlying cancel method with error
error value to be injected from outside
'true' when the task was still pending and the error was applied
Return underlying promise in order to await result
Read the settled result when the task has already finished
settled result, or null when the task is still pending
Task monad interface