With the addition of async / await to TypeScript using Promise(s) can look very syntactically close to Task(s).
Example:
Promise (TS)
public async myAsyncFun(): Promise<T> {
let value: T = await ...
return value;
}
Task (C#)
public async Task<T> MyAsyncFun() {
T value = await ...
return value;
}
I was wondering if the other way around, there was an equivalent to .then() for Task(s).
Example:
Promise (TS)
Promise<T> promise = ...
promise.then((result: T) => ...do something...);
Task
continuations (msdn.microsoft.com/en-us/library/ee372288(v=vs.110).aspx). There are also some other interesting methods such as theWhen...()
andWait...()
methods (msdn.microsoft.com/en-us/library/…)