Тёмный
No video :(

Async Generators - Javascript In Depth 

Tech with Nader
Подписаться 12 тыс.
Просмотров 2,7 тыс.
50% 1

Опубликовано:

 

26 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 27   
@fabioescobar5463
@fabioescobar5463 Год назад
You are very clear in explaining bro! You anticipated all the mistakes I was going to make LOL
@TechWithNader
@TechWithNader Год назад
Thanks Fabio! Haha, that's good to hear! This is quite a tricky topic so I hope it was useful 😊
@shivamgupta3652
@shivamgupta3652 Год назад
Exactly
@jjjj5452
@jjjj5452 2 месяца назад
yeah there was a lot going on here, but you've made it clear, thanks
@tomboolery
@tomboolery Год назад
Generators seem ridiculously powerful, with async generators even more so. I can’t wait to progress and see how we’re going to be using them in tandem with APIs (the idea that we can input into .next() to influence yield returns got my mind racing). Thanks again Nader you’re helping so many people ✌🏼
@TechWithNader
@TechWithNader Год назад
Hey Tom - Definitely super cool, haha! It's an important and fancy concept that underpins a lot of underlying stuff in JS and even other languages 😊
@shivamgupta3652
@shivamgupta3652 Год назад
Other youtubers finish these topics in 5 minutes. But your way of teaching is totally different that a student cannot forget the concept. Every person should persue through your course who wants to learn JS
@TechWithNader
@TechWithNader Год назад
Thanks Shivam! That pretty much sums up my approach to teaching, so I'm glad it's coming across and you're finding it helpful! I was curious to know if people would be ok with such long-form content on RU-vid 😃
@shivamgupta3652
@shivamgupta3652 Год назад
@@TechWithNader well everyone who learns programming should know, good things take time, especially programming so i would not mind if they will be more longer
@TechWithNader
@TechWithNader Год назад
💯 couldn’t agree more!
@Kiran-khadka
@Kiran-khadka Год назад
Wow! Your tutorial are great 🖤 Love your content 💓 I wish if you have started earlier so that I should not have to jump between tutorial to know what's actually is happening! Because you cleared all the concepts as possible so that beginner like me felt comfortable with the Concepts relates to topic 🖤 Wow wow wow👀
@TechWithNader
@TechWithNader Год назад
Thanks Kiran! That means a lot to me 😊 I’m glad you’re learning so much and clearing up concepts you wanted to know more about. Let me know if you have any ideas or feedback for other topics 😊
@dsstudios178
@dsstudios178 Год назад
Theres a weird thing going on. Code similar to what you used: function* foo_gen() { yield new Promise((resolve, reject) => { setTimeout(() => { resolve("Finished!"); }, 3000); }); } for await (const promise of foo_gen()) { console.log(promise); } Gives same error for me in node, but in the browser's console this gives no error and returns "Finished!" after the 3 seconds. Why? We can also replace foo_gen() with a `new Promise()` but it will error if it isnt in a array?? [new Promise()] This feels very strange...
@dsstudios178
@dsstudios178 Год назад
I found somewhat of an answer for people curious. chrome seems to have a `top-level await` that makes this work, its likely node doesnt have this. So this top level await will await any value passed to the for...of loop's variable. This means when we pass a promise: `for await ( const promise of new Promise(...))` we error, as a promise is an Object, not iterable. But if we did: `for await ( const promise of [new Promise(...)])` Its in an iterable array now and now `promise = new Promise(...)` which will be awaited. This works with the generator function for the same reason, when the `for await (const yielded_promise of generator())` runs, like we know by know, the loop will run generator.next() and assign the yield value to the `yielded_promise` variable. So once again we will await this value :D Please note, this seems to not be in node, but in the google console. Also it will technically await ANY value, `await 5;` for example. Someone feel free to correct me, hope im on the right track about this, but for now imma stick to normal node.js
@TechWithNader
@TechWithNader Год назад
Interesting finds! What was your original error, in Node? Deno which is another newer runtime also has a 'top level await' feature, which can be nice if used correctly haha 😊
@Abulkhair1995
@Abulkhair1995 Год назад
your chanel grows more I wish...
@DannyGorelik
@DannyGorelik Год назад
That's very nice thank you for the explanation :) But how can i mock these functions for testing?
@TechWithNader
@TechWithNader Год назад
Hey Danny! Good question - it really depends on the testing library/framework you're using. It would be similar to testing any other Promise-based functionality. Lots of them allow you to "await" the tests and verify their results before moving on to other non-related tests 😊
@jeremiahabiola994
@jeremiahabiola994 Год назад
Nice video man.
@jeremiahabiola994
@jeremiahabiola994 Год назад
Please after this series make a video on api. Json and ajax. They are confusing..
@TechWithNader
@TechWithNader Год назад
I totally agree and that is the plan! Do you think it would be more helpful to have that first or front-end and react first?
@jeremiahabiola994
@jeremiahabiola994 Год назад
I guess the front end. Cause making videos on apis won't be complete without knowing the front end, with the exception of backend devs sha. But it will be a very long series 🤧🤧
@jeremiahabiola994
@jeremiahabiola994 Год назад
@@TechWithNader It depends on your plan.. I feel combining the two might be stressful... Html ,css.. A lot to cover especially in css.
@jeremiahabiola994
@jeremiahabiola994 Год назад
@@TechWithNader I feel you should focus more on the backend
@ShivamSharma-dq4pu
@ShivamSharma-dq4pu 4 месяца назад
30:50 you say that for await (const promise of asyncGeneratorObject) { console.log(promise); } will not work for normal generator but i try to ran at but it ran just fine. const normalGenerator = function* () { let i = 0; while (true) { yield new Promise((resolve, reject) => { setTimeout(() => { resolve(i); i++; }, 1000); }); } }; const normalGeneratorObject = normalGenerator(); const asyncGeneratorExecuter = async () => { for await (const promise of normalGeneratorObject) { console.log(promise); } }; asyncGeneratorExecuter(); this is working fine
Далее
Exercises: Async Generators - Javascript In Depth
31:54
Symbols - Javascript In Depth
28:54
Просмотров 1,7 тыс.
Can You Bend This Bar?
01:00
Просмотров 3,9 млн
Ajdarlar...😅 QVZ 2024
00:39
Просмотров 377 тыс.
Advanced Async and Concurrency Patterns in JavaScript
39:43
JavaScript Modules Crash Course
48:38
Просмотров 47 тыс.
Objects - Javascript In Depth
40:11
Просмотров 2,9 тыс.
Network Protocols - Rest APIs In Depth
33:14
Просмотров 1,4 тыс.
From zero to Async API
1:29:55
Просмотров 8 тыс.
The "this" Keyword - Javascript In Depth
1:04:30
Просмотров 3 тыс.
I tried React and it Ruined My Life
1:19:10
Просмотров 124 тыс.
Sets - Javascript In Depth
15:23
Просмотров 1,4 тыс.
Exercises: Objects - Javascript In Depth
50:54
Просмотров 3,4 тыс.
Can You Bend This Bar?
01:00
Просмотров 3,9 млн