DEV Community

Discussion on: An async/await gotcha

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

I'm sorry but you not moving from promises, your still using promises?

Collapse
 
tyrw profile image
Tyler Warnock

We are rewriting as we go. We have about 350,000 lines of code, so it's a process 😃

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

But why? Sorry I don't mean to be the negative rubber duck. Async Await (good idea for greenfield projects) but this is syntactic suger that makes little difference because under the hood it's still a promise.

Thread Thread
 
tyrw profile image
Tyler Warnock • Edited

We're not actively going through the codebase and replacing things, but we are able to eliminate a lot of extra scoping and syntax by using async/await as we make changes or add new features.

For example if you want to use the result of a promise several .then calls later, you have to either nest your promises or use a scope variable. With async/await you don't, so it has a nicer tidiness factor.

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

Agreed promises if used in a certain way, can cause a form of callback hell. How many promises are there in your codebase. 35000 lines doesn't really explain the size of it. To clarify I have been using async await way back when they dropped in typescript last year. I love them.

Thread Thread
 
tyrw profile image
Tyler Warnock

How many promises are there in your codebase

Lots of them, maybe 5-10k?

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

Jeez well if it make your codebase cleaner, I can see why now. Thanks for sharing the post 😀.