Node.js Tutorial - 42 - Event Loop
HTML-код
- Опубликовано: 12 янв 2023
- ⚡️Syncfusion components: syncf.co/3Emhvnv
📘 Courses - learn.codevolution.dev/
💖 Support UPI - support.codevolution.dev/
💖 Support Paypal - www.paypal.me/Codevolution
💾 Github - github.com/gopinav
📱 Follow Codevolution
+ Twitter - / codevolutionweb
+ Facebook - / codevolutionweb
📫 Business - codevolution.business@gmail.com
Event Loop
Node.js Tutorial
Node.js Tutorial for Beginners
You are literally the only person that, when explaining, makes me remember all I listened and watched. Amazing. Don't know how you do it. Thank you.
Was about to say the same thing!
What don't you get? Vishvas is a Master teacher, that's why.
One of the best high-level explanation of the event loop, ever!! Thank you so much for this.
This content is gold, hope you're planning for the cluster module and (exec, spawn, fork) with deep explanation in your next vods
Impressed by the flawlessly flowness of teaching.
I swear I love you. I'll learn anything you teach. Now I can picture the event loop. I'm happy. I'm just walking around and laughing
Best nodejs playlist I ever came across youtube
Hands down the best presentation on this topic! Wow! Thank you.
Thank you, Vishwas for this fantastic course. you are always the best choice to explain any topic
this is by far one of the brilliantly articulated video out there that too for free wrt node js event loop... thanks a ton
Thank you, thank you! You are a star and you have earned a subscriber. Well explained and I now have the required confidence to understand as to what is going on the event loop.
The way yo taught this process of event loop amazed me. Hats off to your skills.
Great explaination on event loop!! Thank you.
Wonderful work, sir. I read some article in internet and noone more clear than your video. Thank you so much
you are a god in a mortal's body. the best explanation till date
Really great explanation and on point with visual representation 👍
You are the best 💡
I saw a lot of vids and tuts but this demonstration is simply amazing
best explanation of event loop to date. no one does better.
The best explanation i ever watched of this topic. I have been facing a lot of trouble lately understanding javascript's async behaviour. I think i am gonna find the solution here only. Too good. Really appreciable.
this course is a treasure
That was very well explained, thank you
really great representation and explanation 😎 awesome as always
Very informative video with visual representation and it's explanation. Thank you
Thanks a lot sir Vishwas,ypu're an incredible teacher
thanks teacher, 42 it was great!
The Only Best Video On RUclips or in any paid video about the explaination of event loop... hats off to vishwas 🫡🫡🫡🫡
Best nodejs event loop explanation, thank you 😍
amazing, best explaination ever!...
설명 진짜 개쩐다 말이 안됨... 이사람은 신이야
Great explanation!
Well researched video. No video of event loop on youtube told me that the libuv is just a C program. Nice.
visual representation is more effective than explaining thing without it. Thanks @vishwas sir.
That was some great explanation
Waaaoo!! Is a great experience to watch this just like a good movie.. It is so entertaining and digestable for this articulated concept. Is very enjoyable to have this understanding, how everything fits! 👌🍿🔥
Beautiful explanation ❤❤❤❤❤
Thanks man!!
that was really nice
Thank you Vishwas 🙏🏾
The best explanation I have ever had on the event loop. you rock Vishwas. Thanks for the video
THANK YOU VERY MUCH FOR THE COURSE!!
Best explanation yet.
Great explanation sir..😍😍😍
great explanation
Great knowledge sharing video
Thanks a lot 🙏
Oh damn! This is useful
Helpful video
Thanks!
wow thanks again
waiting for express js tutorials
8:30 the event loop visualization and the different queues inside it
Hi Vishwas, thanks for the amazing content. Looking forward to the Express course, when are going to drop it?
Many thanks. How many videos are planned for this playlist?
just wanted to ask what would be the last topic fo the event loop playlist?
variables are stored on the call stack, not the memory heap.
I am wondering how those tasks in the low-priority queues are executed at all
Liiiii__Buuuu__V_________ 😀 ! Loved it ! Man thanks for this explaiation ! 👍
setImmediate seems to run before setTimeout, does that mean check queue is executed first before timer queue ?
I'm on node v20.14.0
setTimeout(() => console.log("timeout"))
setImmediate(() => console.log("immediate"))
ouput:
immediate
timeout
I think there's a mistake around the 11:32 mark on step number 3. Based on my understanding, If a task in the timer queue (or any macrotask queue) enqueues a microtask (say you have a promise inside a setTimeout callback) the event loop will not execute the other macrotasks in that queue and start executing from the microtask queue until it is empty again.
this code snippet prints 1, 2, 3, 4, 5, 6
function main() {
console.log('1');
setTimeout(() => {
console.log('3');
// this is a microtask within the callback of a macrotask
process.nextTick(() => {
console.log('4');
});
// this is a macrotask within the callback of a macrotask
setTimeout(() => {
console.log('6');
}, 0);
}, 0);
setTimeout(() => {
console.log('5');
}, 0);
process.nextTick(() => {
console.log('2');
});
}
main()
Thanks for the video! I need to point out that Execution order is incorrect.
The micro task queue will not wait for all callbacks within the timer queue are executed. Instead for Node 11+ nextTick callbacks and microtasks will run between each individual setTimeout and setImmediate callbacks, even if the timers queue or the immediates queue is not empty.
Yes, I tested this.
Hey,
I have a question - for any queue other than the Microtask queue will the event loop wait for it to finish with all of its callbacks before checking in with the Microtask queue, or will it check the Microtask queue after when each and every callback is executed and popped off from the call stack.
Considering the call-stack is now empty, it should ideally check with the Microtask queue first before picking up any other cb() from the other queues.
Hope, I am able to explain my question.
Thanks.
I got my answer from the following sessions, so please ignore.
Although I think this video @11.37 seconds needs to be corrected as it says in point no #2,#4,#6,#8 seems a bit misleading to me
Great content. Please upload RXJS videos please
Gooo job however, i will be glad if you can use explain the last-in-first-out principle using the console
🙏🙏
You said javascript is synchronous but the new javascript - ES6 uses async functions? Am a bite confused
just watched 4:30 and i already your fan sir... you got my sub, my support and lots of love (^_^)
It’s better to show the order of execution or priority in the diagram itself
Sr can you do a series about SOLID pirnciples on a react app please?
GODDDDDDDDDDDDD
HOW TO GET HOLD OF YOUR SLIDES? PLEASE PLEASE PLEASE REPLY ❤
Great explanation, but isn't it a mistake in 11:20? "All callbacks within the timer queue are executed" - is it true? Not only limited amount of them?
What about the events created by eventemitter there is no details about it
But JavaScript is non blocking
Please explain
The cycle diagram appears to be outdated. I would recommend referring to the official site for an updated explanation, which is provided below:
- A process.nextTick callback is added to process.nextTick queue. A Promise.then() callback is added to promises microtask queue. A setTimeout, setImmediate callback is added to macrotask queue.
- Event loop executes tasks in process.nextTick queue first, and then executes promises microtask queue, and then executes macrotask queue.
could you pls point me to some reference that talks about this change. I'm very confused rn
NodeJS be like: Yeh toh Dhoti khol raha hai
you have mentioned setTimeout and setInterval callbacks are given first priority, but actually..........
In the Node.js event loop, the execution of setTimeout and setInterval callbacks is not given first priority. These callbacks are enqueued in the event queue after their specified delay or interval, and they are not immediately executed when their time is up. Instead, they will be executed only when the event loop has the opportunity to process them.
Also he said that synchronus code will always run before async code. That's why call stack needs to run synchronus code first. When stack got empty then event loop will start to push async code.
The event loop works in a loop...
Recall the diagram..setTimeout and setInterval are given first priority but even loop works in a loop..if it is in the middle of the evvent loop, the timeout events have to wait till loop is complete and their turn comes
Redis Series please 🙂!
Do you really need to understand all of this? I just have to 'know node' for work. I'm thinking of skipping these Event Loop videos, go straight to the NPM videos.
What will be the order of execution if we have setImmediate and setTimeout(fn,0) @codeevolution
console.log("Start");
setTimeout(() => {
console.log("Timer Callback 1");
}, 1000);
setTimeout(() => {
console.log("Timer Callback 2");
}, 500);
const fs = require('fs');
fs.readFile('example.txt', (err, data) => {
if (err) {
console.error("I/O Callback (Read File) Error:", err);
} else {
console.log("I/O Callback (Read File)");
}
});
setImmediate(() => {
console.log("Immediate Callback");
});
console.log("End"); when im trying to run this code timer queue callbacks running after all the callbacks why according to priority timer queue should run first right
Just one word for you AWESOME🥸