π¬ A Q&A with… Valeri Karpov
JavaScript book author and trainer
Miami Beach, Florida
Valeri, also known as The Code Barbarian, is a prolific author of JavaScript tutorials and books and was also the person to coin the term MEAN (as in the MongoDB, Express.js, Angular and Node.js stack). To celebrate the release of his new book, Mastering Async/Await, we've asked him a few questions:
You're a very prolific JavaScript blogger - what's your secret?
I don't have any special secret, I've made a personal commitment to writing regularly because I find it helps me refine my ideas. I spend a lot of time coding, and I write as a way to identify general principles from the day-to-day of finding bugs and adding features. Writing gives me a great excuse to try out new libraries or frameworks.
Have you seen any ways in which async/await are overused or misused that people should avoid?
The most glaring issue is using async/await with a framework without looking to see if the framework actually supports it! There's probably a lot of developers out there wondering why their async Express route handler isn't sending a response or why their React component's async componentDidMount function isn't working with server-side rendering.
I also see a surprising amount of code that uses async /await mixed with classic callbacks or promise chains. While passing an async function to a promise's then() function as shown below is valid, it misses the point of async/await:
|
No comments:
Post a Comment