Generator Functions will make your code cleaner 🧹
HTML-код
- Опубликовано: 15 июл 2024
- In this TypeScript tutorial, you will learn how to encapsulate your data-fetching functionality in a generator function. This approach will enhance the reusability of your code, as consuming code can simply use for-await to fetch the data.
My FREE programming apps:
- apps.apple.com/app/id659282498
- play.google.com/store/apps/de...
My FREE TypeScript Course:
- typescript.tv/
Timeline:
00:00 - Intro
00:31 - Fetching Data with Async-Await
05:52 - Turning Functions into Generator Functions
09:56 - The Benefits of Generator Functions
11:01 - Bonus: Converting JSON Data into a Zod Schema
Resources:
- polygon.io/stocks
- transform.tools/json-to-zod
#typescript #javascript #nodejs Наука
Juat discovered the channel today and instantly fell in love with it. The quality of videos are very high. I love typescript. I myself created one course on node and ts long back. Now i work with go and miss typescript. Your contents help me sharpen my knowledge. Please continue making more and more contents.
Thank you so much! Where can I see your Node.js & TS tutorial? I am curious! 👀
@@TypeScriptTV i am trying to comment the video link but it seems to be deleted by youtube. I don’t know why.
Very clear video, thanks!. This could be a great use case for streaming responses then ?
Absolutely! Here, you can see a streaming case: typescript.tv/hands-on/all-you-need-to-know-about-iterators-and-generators/#case-2-fetching-remote-content
You could've gone one step further and had the generator yield the individual results so instead of the consuming code iterating over chunks, it would iterate over results.
Great idea! Thanks for suggesting it. I'll definitely add this approach to my blog. 👍