#54 async and await now


Idea submitted by Devin Weaver
Promises are great but there is a better way to deal with asynchronous calls.  Use the async/await pattern which is an ES7 feature but you can enable it in ember.  Simply edit your ember-cli-build.js file and add:

And now instead of writing:

You can write:

It’s much easier to read and reason about and when you have several levels of nesting, it will be super easy to understand and write.

Problem: The generated javascript code is ugly to debug in chrome – but manageable.

Credits & Links

Thank you Devin for the tip idea
Learn more about async/await and ember at http://snip.ly/t8cwh
Good read on Javascript async/await at http://snip.ly/7opuv

Free Programming Books and lifetime access to IconApp.io

I am giving away some programming books and lifetime access to iconapp.io library of awesome icons.  Check it out at https://gleam.io/XqHjW/rock-and-roll-with-emberjs

Share A Tip

Let us know if you have a good ember tip (you will get full credit)
If you are enjoying my daily tips please spread the word with this one-click tweet.
If you do NOT like the tips then please reply to this email and let me know how I can improve them.

Published by

Emad Ibrahim

Author of asp .net MVC & TDD, entrepreneur, passionate technologist, programmer and productivity nut. more at http://t.co/oSJXPvzu