0

Co bills itself as a "stepping stone towards ES7 async/await", but I'm not really sure why I should use it over just writing async functions and using babel to compile. Are there any advantages and disadvantages to these approaches or is it just a question of preference?

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
  • async/await is not part of ES7. – Felix Kling Jun 22 '16 at 14:48
  • *"I'm not really sure why I should use it over just writing async functions"* you don't have to. As it says it's a stepping stone *towards* async/await. If you can use async functions with Babel, then do that. – Felix Kling Jun 22 '16 at 14:50

1 Answers1

2

Async/Await is more like writing sync code and is where es is going. It's just syntax to make it simpler/more intuitive to write async code.

Evolution of Async Syntax:

callbacks --> promises --> async/await

This article shows how the syntax can make certain situations much more concise and arguably more intuitive.

Community
  • 1
  • 1
JohnnyFun
  • 3,975
  • 2
  • 20
  • 20
  • Doesn't really address the question IMO. – Felix Kling Jun 22 '16 at 14:50
  • Well, my answer as to why he might use it is because that's where ES is going, but your above point about async/await not being included in ES7 might make my point moot. – JohnnyFun Jun 22 '16 at 14:52
  • Yeah I much prefer writing async/await functions, I guess I'm just confused as to why co even exists/is so popular. Felt like there was something I was missing. – Joe Bushell Jun 22 '16 at 14:58
  • @JoeBushell: not everybody wants to transpile their code. – Felix Kling Jun 22 '16 at 15:00
  • @FelixKling fair enough, I guess that's my question answered. Thanks for the help, I think I spend too much time worrying if I'm doing things 'right'. – Joe Bushell Jun 22 '16 at 15:04