Node.js Tutorial - 42 - Event Loop
ฝัง
- เผยแพร่เมื่อ 20 ก.ย. 2024
- ⚡️Syncfusion components: syncf.co/3Emhvnv
📘 Courses - learn.codevolu...
💖 Support UPI - support.codevo...
💖 Support Paypal - www.paypal.me/...
💾 Github - github.com/gop...
📱 Follow Codevolution
+ Twitter - / codevolutionweb
+ Facebook - / codevolutionweb
📫 Business - codevolution.business@gmail.com
Event Loop
Event Loop in Node.js
Node.js 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.
yes I have same experience
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
Best nodejs playlist I ever came across youtube
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
gay
Hands down the best presentation on this topic! Wow! Thank you.
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 is by far one of the brilliantly articulated video out there that too for free wrt node js event loop... thanks a ton
The way yo taught this process of event loop amazed me. Hats off to your skills.
Thank you, Vishwas for this fantastic course. you are always the best choice to explain any topic
the second time watching this video after one week and getting know well. Thank you a lot
You are the best 💡
I saw a lot of vids and tuts but this demonstration is simply amazing
visual representation is more effective than explaining thing without it. Thanks @vishwas sir.
you are a god in a mortal's body. the best explanation till date
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.
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! 👌🍿🔥
best explanation of event loop to date. no one does better.
This is the best explanation of nodejs event loop
The best explanation I have ever had on the event loop. you rock Vishwas. Thanks for the video
Wonderful work, sir. I read some article in internet and noone more clear than your video. Thank you so much
Well researched video. No video of event loop on youtube told me that the libuv is just a C program. Nice.
Best nodejs event loop explanation, thank you 😍
this course is a treasure
Great explanation!
Thanks a lot sir Vishwas,ypu're an incredible teacher
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()
It’s better to show the order of execution or priority in the diagram itself
That was very well explained, thank you
THANK YOU VERY MUCH FOR THE COURSE!!
Best explanation yet.
Great explaination on event loop!! Thank you.
amazing, best explaination ever!...
8:30 the event loop visualization and the different queues inside it
설명 진짜 개쩐다 말이 안됨... 이사람은 신이야
Very informative video with visual representation and it's explanation. Thank you
Beautiful explanation ❤❤❤❤❤
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.
Really great explanation and on point with visual representation 👍
The Only Best Video On TH-cam or in any paid video about the explaination of event loop... hats off to vishwas 🫡🫡🫡🫡
variables are stored on the call stack, not the memory heap.
thanks teacher, 42 it was great!
Thank you Vishwas 🙏🏾
really great representation and explanation 😎 awesome as always
that was really nice
That was some great explanation
Great knowledge sharing video
waiting for express js tutorials
Gooo job however, i will be glad if you can use explain the last-in-first-out principle using the console
Thanks!
Great explanation sir..😍😍😍
Many thanks. How many videos are planned for this playlist?
Hi Vishwas, thanks for the amazing content. Looking forward to the Express course, when are going to drop it?
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?
it's the best explanation, thank you so much
Bro You mistakenly said js is blocking but JavaScript itself is not inherently blocking or non-blocking; it depends on how it's used in different environments. In the context of web browsers, JavaScript traditionally operates in a non-blocking manner, especially when handling asynchronous tasks like fetching data from a server. However, JavaScript code can be written in a blocking manner if operations are performed synchronously without utilizing asynchronous capabilities.
The other lecture is good, keep it up
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
great explanation
Thanks
Thanks man!!
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
Thanks a lot 🙏
Oh damn! This is useful
HOW TO GET HOLD OF YOUR SLIDES? PLEASE PLEASE PLEASE REPLY ❤
You said javascript is synchronous but the new javascript - ES6 uses async functions? Am a bite confused
I am wondering how those tasks in the low-priority queues are executed at all
Does promise queue is same as promise function of javascript?
Great content. Please upload RXJS videos please
Liiiii__Buuuu__V_________ 😀 ! Loved it ! Man thanks for this explaiation ! 👍
wow thanks again
Helpful video
just watched 4:30 and i already your fan sir... you got my sub, my support and lots of love (^_^)
just wanted to ask what would be the last topic fo the event loop playlist?
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
Sr can you do a series about SOLID pirnciples on a react app please?
What about the events created by eventemitter there is no details about it
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
🙏🙏
GODDDDDDDDDDDDD
NodeJS be like: Yeh toh Dhoti khol raha hai
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.
Your loss
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🥸