3 ms·
It's lovely how Promises appear to be, in design, virtually equal to Tasks in the .NET library. This should make them very easy for C# programmers to understand
by skrebbel 14y ago
It's lovely how Promises appear to be, in design, virtually equal to Tasks in the .NET library. This should make them very easy for C# programmers to understand.
`then()` is called `ContinueWith()`. .NET Tasks unfortunately lack the progress callback. In turn, JS Promises appear to lack the ability to cancel a running operation. Otherwise, they're nearly exactly the same.
I'd take this stuff over callback-passing anytime. I hope it becomes commonplace.
- domenicd 14y agoYes, very true! In fact, many of the the Windows Runtime APIs are async. They get projected identically into C# with `Task` as they do into JavaScript with WinJS promises. On cancellation, this is actually a feature of several promise libraries. When.js has it, as do WinJS promises (so those cancellable Windows Runtime APIs project just as well into JavaScript). We are hoping to add the feature to Q, but we haven't figured out the exact semantics yet, especially with regards to some of the object-capability security requirements Q attempts to address. Of course, C# 5 has a huge advantage in their `await` and `async` keywords. But fear not! Shallow coroutines with `yield` are coming in ECMAScript 6 (the next version of JavaScript), and you can build very similar support on top of promises: http://taskjs.org/ http://taskjs.org/