-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adopt async/await where approriate #70
Comments
async
/await
where approriate
Early research appears that for the ES5 down emit, TypeScript expects We already had to do this with Also, our Also, we considered in dojo/shim#16 adding the cancel functionality to |
Async/Await with
|
My feeling was that we would go with the last option. I would agree that we should have a separate set of unit tests for async/await with our promise implementation (outside of the We also need to check that our solution would place nicely with Bluebird, potentially even including a set of tests for that, and that it is roughly "transparent" if someone uses Bluebird instead of our Promise implementation. |
@kitsonk how do you see most people using Bluebird? If they just import it like this, they can use it along side of our promise solution (similar to solution 1) import * as Blue from 'bluebird';
async function beUseful() {
return Blue.resolve(1);
} It looks like if you include Bluebird via a script tag however, it inserts itself into the global scope. |
I am thinking they would use that as the global Promise solution. We would still write internal code, which needed to make sure the import 'dojo-shim/Promise`; But that shouldn't interfere with someone using Actually I realised an issue with your first suggestion, it is the default export, which people may still want to do: import DPromise from 'dojo-shim/Promise';
async function do(): DPromise<boolean> {
return DPromise.resolve(true);
} |
OK, I wrote some tests that use async/await using Bluebird (with dojo promise not loaded), Dojo promise (with bluebird not loaded), and Bluebird with dojo promise loaded. Everything seems to be working as intended :) The code can be seen here, |
PR is here, dojo/shim#64 |
PR merged |
Down emitting
async
/await
when targeting ES5 is available in TypeScript 2.1.0-dev.20160907 or later.We need to investigate how we can utilise this with our
dojo-shim/Promise
and adopt the pattern which will make many async code more readable without needing a complex chain of.then()
callbacks.The text was updated successfully, but these errors were encountered: