Тёмный
No video :(

Understanding EventEmitter | Understanding Node.js Core Concepts FREE VERSION 

Cododev
Подписаться 9 тыс.
Просмотров 24 тыс.
50% 1

Grab the complete and premium version of the course using this link:
www.udemy.com/...
In this video, we'll understand what exactly EventEmitter, which is an important object in Node.js, really is.
The Course - Free Version: • Understanding Node.js ...
Code your own event emitter in Node.js: www.freecodeca...
Learn those JavaScript concepts from this page: www.pagser.com...
UPDATE (June 2022): As Arthur mentioned in the comments, there's still an issue in the events.js source code, and that quick fix will now regard all onceWrapper functions as the same thing. This will be problematic if we declare multiple once listeners with the same event name. If you take a look at the Node.js events.js file, you'll see how Node.js is handling those "once" functions.
I'll post an update if I get the chance to fix this issue. I'll also appreciate it if you can share your solutions to the problem if you come up with one!
--------------------------------------------------------------------
My LinkedIn Profile: / joseph-heidari
Cododev Website: www.cododev.ca/

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

 

25 авг 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 88   
@viridianite
@viridianite Год назад
00:00 Introduction 3:46 What's the EventEmitter object? 5:14 Example of events in the OS 11:12 Diagram: What happens when 'on' and 'emit' methods run 14:05 Code: Running the example 17:50 Diagram: The 'once' method in the EventEmitter class 19:42 Reading the NodeJS docs about the EventEmitter class 23:40 Looking over an implementation of the EventEmitter class 31:42 Looking over the source code of the EventEmitter class in NodeJS 34:38 Final words
@kmmonzurulislam3454
@kmmonzurulislam3454 2 года назад
This is how you explain a complicated topic. Thanks for making such a helpful video and helping us. You got one more subscriber! Please keep going...
@arthurfedotiew3609
@arthurfedotiew3609 2 года назад
The one thing I personally didn't like is INTENTIONAL skipping of proper computer science terminology. Imho, it's only beneficial to us, students, to hear as much as possible proper terminology used for explanation from the get go. That is very confusing in a web to understand all this stuff like concurrency, parallelism, push-pull, etc. This is due to the fact that there is lot of frauds, and you are NOT one of them. You have a deep knowledge and great skills of teaching. Please use all of your knowledge, since it's a precise for all of us! Apart from that, everything is at highest level of professionalism! Keep it up!)
@Cododev
@Cododev 2 года назад
Hi Arthur, sorry for my late response... I think it's necessary to mention these computer science terms, due to two main reasons. One is that some students already possess some knowledge in CS, maybe they have studied CS in university, or somewhat somehow have learned these concepts through their experience, and then mentioning them here will make the concept easier for them to grasp and make better connections in their minds. And another is that some people are just curious to know and would research some of these terms and learn about them, which will ultimately result in a deeper knowledge of the technology. The downside is that some students neither have a CS background nor care to learn about them and these terms may only confuse them if used too much. But I should take better care here, focus on a more complete and accurate use of these terms, or maybe give a pdf file with each video that incorporates all these terms with some description and probably links to learn more... I hope I could make some improvements in this regard! and thanks for your comment Arthur!
@psaintjean11
@psaintjean11 2 месяца назад
Excellent Lesson!! I am new to coding, new to JavaScript and I could understand better the concepts of the programming language. Thanks for explaining thoroughly event emitters.
@procodrr
@procodrr 11 месяцев назад
📖 Chapters 00:00 - Understanding EventEmitter 02:20 - On and Emit Methods on Emitter Object 04:55 - Understanding the Event-Driven Nature of OS 08:15 - Understanding the Event-Driven Nature of Node.js 10:26 - How EventEmitter Works Behind the Scenes? 17:35 - Once Method on Emitter Object 19:27 - Learn More About EventEmitter from Node.js Docs 23:16 - Creating Our Own Version of EventEmitter 31:38 - Taking a Look at the Source Code of Node.js for EventEmitter 34:36 - Wrapping Up
@user-lw6jt1nt4k
@user-lw6jt1nt4k Год назад
thanks, finally found some in-depth node tutorial
@confusedguy2273
@confusedguy2273 Год назад
Thank you for your videos....they really help to get a deep insight into how Node works..There are very few creators who make such high quality videos on core concepts ..Thank you..Hope to see your more videos on various topics in future...(P.S your video Nodejs Under the hood really helped me at a recent interview...Thanks to you I cleared it..)🤗
@YoannBuzenet
@YoannBuzenet 2 года назад
thank you !!! Please continue !!
@bicube7529
@bicube7529 Год назад
ok, i'm feeling that I didn't know javascript before. i truly understand now how the event emitter works
@hgsbrodi
@hgsbrodi 2 года назад
Nice, I was watching videos on design patterns and observers the other day, and this was a great refresher.
@abhimanyu2350
@abhimanyu2350 Год назад
The once implementation is actually correct, it's only the for loop statement that's buggy @29:46. We can compare the two functions in this case cause we are actually comparing the references to same memory location
@VA-nk6jc
@VA-nk6jc 11 месяцев назад
I noticed that too. The loop simply doesn't reach 0 index. And it's perfectly fine to compare functions (objects) in JS. How the author could not know that? It's quite a serious mistake.
@21adsyeshwanths.25
@21adsyeshwanths.25 Год назад
I would like u to contribute more bro, not sure about others but i have been gaining a lot from you................ Support from India❤
@ptkocz
@ptkocz Год назад
Amazing content 🔥, please keep going with stuff like this! :)
@ChannelUCkG12x
@ChannelUCkG12x 2 года назад
excited to watch the next episodes, thank you very much
@mohammadnashashibi2942
@mohammadnashashibi2942 6 месяцев назад
in the "once" implementation if you had just changed "i > 0" ---> "i >= 0" in the for loop it would've fixed it. You can compare functions in JS by ref which is the wrapperFn in this case. great quality content btw!👌thanks!
@D_Ladybug
@D_Ladybug 10 месяцев назад
Juat stumbling on this playlist and I'm addicted already. Could you please teach us C too?
@manasupadhyay266
@manasupadhyay266 2 года назад
Excited to learn how http module works😁
@Cododev
@Cododev 2 года назад
It's coming up next after File System, Streams, Net and then HTTP!
@manasupadhyay266
@manasupadhyay266 2 года назад
Waiting for your next video 😅
@YoannBuzenet
@YoannBuzenet 2 года назад
@@manasupadhyay266 +1 :D
@suyashpurwar631
@suyashpurwar631 Год назад
@@Cododev Please bring it on. Include HTTP/2 and HTTPS.
@suyashpurwar631
@suyashpurwar631 Год назад
Please complete this course!
@Talel_kraiem
@Talel_kraiem Год назад
best explanation on youtube 😋 please , please continue ❤
@hariprasath9985
@hariprasath9985 2 года назад
Eagerly waiting for your next video
@memduhcevik
@memduhcevik Год назад
These are exactly what I need ❤
@exe.m1dn1ght
@exe.m1dn1ght 9 месяцев назад
Thank you so much Master for this video
@CalebStephensPlaysPiano
@CalebStephensPlaysPiano Год назад
Thanks! These videos are just what I need!
@vishalbhalothia
@vishalbhalothia 2 года назад
Great videos 👍👍👍👍👍 Need more and more videos.... complete node js list...
@mykun8737
@mykun8737 Год назад
Dear Cododev, could you please add a timestamp to the video's table of contents and include the source code for the video, placing it in the description section? I'm thrilled that you are the only one teaching about Node.js core. In the outside world, people seem to be solely focused on teaching frameworks like Express.js.
@gaminghunter800
@gaminghunter800 Год назад
wow, amazing....thanks for this knowledge 🤩
@thiagowwz
@thiagowwz 3 месяца назад
*_a m a z i n g_* lesson, whoa!
@tomasgilamoedo8301
@tomasgilamoedo8301 Год назад
Excellent course sir!
@hamzaraza9804
@hamzaraza9804 9 месяцев назад
Amazing video man!
@sergioramos4562
@sergioramos4562 Год назад
Good job!!! Please keep going
@jj342
@jj342 Год назад
Great video! Thanks! (completed!🎆 🍾)
@kobudnik
@kobudnik Год назад
Stellar video
@andrepadez
@andrepadez Год назад
Great video. Why is it necessary to extend the EventEmitter class and not instanciate from it directly?
@solomonglenda6811
@solomonglenda6811 10 месяцев назад
Wondering too
@kamilp1567
@kamilp1567 Год назад
Great video, learned a lot. Keep it up!
@jamjam3448
@jamjam3448 Год назад
woww. Thanks soo much
@syedsadiq8591
@syedsadiq8591 Год назад
Great Stuff
@probablytomi
@probablytomi Год назад
great explanations! thanks
@dylanm7638
@dylanm7638 Год назад
great, *absolutely* great
@imranalperenbayram7847
@imranalperenbayram7847 8 месяцев назад
amazing. thanks for it
@Manish-hv9qx
@Manish-hv9qx Год назад
brilliant job man :)
@casual_chess
@casual_chess Год назад
you'r awesome❤
@negasonicteenagewarhead
@negasonicteenagewarhead Год назад
Great teaching. can someone tell why there's no content in reference site.
@manasupadhyay266
@manasupadhyay266 2 года назад
Sir, please upload videos , your videos are very different from other node js videos available in RU-vid or any paid course
@zxxcfgh1629
@zxxcfgh1629 2 года назад
Great . keep going👏💫
@kareemmohamed9591
@kareemmohamed9591 2 года назад
please make a course about streams as your explanation is very useful and there is no good resources about streams out there
@hakanaki
@hakanaki 8 месяцев назад
So does it make sense to replaces services with just events? for example when a user signs up, you emit the the sendEmail event.
@PiroCoder
@PiroCoder Год назад
we are missing you 😍
@dixztube
@dixztube Год назад
Great job
@canmertinyo
@canmertinyo 10 месяцев назад
thanks
@giorgikhachidze64
@giorgikhachidze64 4 месяца назад
Why did you create a new class and inherited? What was the point of that exactly? Why didn't you just use the class you already imported?
@muhammedcansoy6131
@muhammedcansoy6131 Год назад
awesome
@suyashpurwar631
@suyashpurwar631 Год назад
Created an infinite loop using two events. Throws error when maximum call stack size is exceeded. const EventEmitter = require('events'); const ee = new EventEmitter(); ee.on('eventOne', function() { console.log(this); this.emit('eventTwo'); }); ee.on('eventTwo', function() { console.log('eventTwo called'); this.emit('eventOne'); }); ee.emit('eventOne');
@ravikishan4116
@ravikishan4116 8 месяцев назад
Why you remove the other videos I want that content please sir
@sergioceballos3046
@sergioceballos3046 Год назад
hey bro amazing tutorials, but what about clusters and workers? It would be great if you can explain it to us. Thanks a lot for your videos. Keep it up man!
@AlanSchooll
@AlanSchooll Год назад
Can you make more videos on node js , express js, and react js performance.
@kartikparmar3496
@kartikparmar3496 Год назад
Your pagser page is empty, there is no list of any articles or anything.
@riyadondiraitreda2819
@riyadondiraitreda2819 6 месяцев назад
Hi man I have some questions. Can. I ask it plais
@gabrielmachado5391
@gabrielmachado5391 Год назад
Thanks!
@suyashpurwar631
@suyashpurwar631 Год назад
So, created a never ending loop ee.on('eventThree', function() { console.log('called'); this.emit('eventThree'); }); ee.emit('eventThree');
@mikejames6452
@mikejames6452 Год назад
Hi one question if any can help . If we pass arguments in event emiiter s once call back function it gets undefined even if we passed it in emit function for that event
@Netpilation
@Netpilation 6 дней назад
do you full time or you are a freelancer , just asking for a freind
@arthurfedotiew3609
@arthurfedotiew3609 2 года назад
Wouldn't your quick fix of removeEventListener remove all "once's" listeners for particular event, taking onto account that wrapper function - onceWrapper.toString( ) is always the same string?
@Cododev
@Cododev 2 года назад
Yeah you're right Arthur, I should've paid more attention to that fix haha. The issue is exactly what you've mentioned, it regards all the onceWrapper functions as the same thing. We'll face the issue if we declare multiple once listeners with a unique event name. For example, 3 once listeners on an object listening to the event 'bar', and each one logs the number like this: '...occurred 1.', '... occurred 2', '... occurred 3'. Now, if we run myE.emit("bar") a hundred times, for example, we should get the logs in this order: '... occurred 1.', '... occurred 2', '... occurred 3'. But, in our code we get: '... occurred 1.', '... occurred 3', '... occurred 3'. But anyway, thanks for mentioning this. I'll try to come up with something better (the node.js solution is also pretty interesting, with 2 wrapper functions, a fired state...), in the meantime I'll update the video description to mention this issue, thanks again!
@squarerootof2
@squarerootof2 Год назад
@@Cododev I think the code from freecodecamp is designed to be run with named functions because removeEventListener is trying to compare two references and if you push anonymous functions onto the array when adding listeners there are no references to compare. No sure though since I've only just started learning this quirky, weird language and I haven't really tried the code yet, lol. Great channel.
@deepdive4181
@deepdive4181 Год назад
do a a video on streams
@NitinMandale-sm6th
@NitinMandale-sm6th Год назад
why are we creating Emitter class which extents from EventEmitter and dont have anything inside it... cant we directly create a instance of EventEmitter ?? please clarify
@viridianite
@viridianite Год назад
Think of the EventEmitter class an interface that classes that extend it must abide by. There's not much point on simply extending the EventEmitter class and not implementing the necessary emitters.
@miggu
@miggu 11 месяцев назад
Not necessary for this particular example, but useful if you want to create a class that contains its own methods, those methods in this case would typically be listeners.
@gouthamkrishna5490
@gouthamkrishna5490 Год назад
DO I need to know about core concepts before creating own projects.I mean Im stuck in a particular level I cant go beyond that.
@danko5678
@danko5678 Год назад
I suggest renaming master object to main object
@Cododev
@Cododev Год назад
That is a great point! Thanks for mentioning it!
@halalmeatshophk
@halalmeatshophk Год назад
when does an "error" event occur ? i assume that .emit('error', ) would only occur if an error is found, but my code is always returning an error. I wonder what is the use of this if it always return an error, instead of only when error occurs.
@viridianite
@viridianite Год назад
Whenever the code that extends the EventEmitter class throws an error and emits as 'error'
@Cododev
@Cododev Год назад
The error event will occur if we do .emit('error', ). It doesn't have to be automatic, you could manually do this. So imagine you have a classroom object extending the EventEmiter that has an event called 'newStudent'. Now in your code you could have a limit for number of students, let's say 30. If we try to add another student once we reach the limit, then we could emit an error indicating that. Hopefully this code will clarify that for you: classroom.on("newStudent", () => { if (students.length < 30) { // adding a new student to our database... } else { classroom.emit('error', new Error("Cannot add more than 30 students.")); } }); // A place to handle all the errors relating to the classroom classroom.on("error", (err) => { // sending the error that was occurred to client res.status(400).send(err.message); });
@mjprakash1780
@mjprakash1780 Год назад
30:31 i think off method should be something like this correct me if i am worng off(eventName) { delete this.listeners[eventName] return this }
@aezazali710
@aezazali710 Год назад
it was not same. once was getting called five times by event.emit('bar')
@valikonen
@valikonen Год назад
I'm JS/TS dev but I'm in doubts node has a future. go and rust it will take all....
@Cododev
@Cododev Год назад
Hi Carnaru, thanks for your comment! Well in response I have to say that is certainly not true. While it is possible in the tech world for a new thing to come out and take over another, Node.js will stay here for years to come. And if it’s going to be overtaken by something else, that’s not going to be Go or Rust. Rust and Go are great technologies, I love working with them, but it’s important to know that Node, Rust, Go, Java, and Python… are just tools and each tool is good for some specific tasks while another may not suit that job well. Now comparing these together will take at least an article and I can’t really say all that in a comment. Go is better at concurrent programming and multi-threading, but still, if you combine Node and C++ (you’ll get the best of both worlds), you’ll come up with something impossible to beat by Go or Rust. I’ve seen lots of articles online saying the cons of Node, but most of them are outdated and really the authors don’t have enough knowledge of Node so they just throw wrong facts at people (mainly it’s because good tutorials and resources that teach node in depth out there are so scarce). Also, for learning purposes, we should focus on the core concepts, topics like Databases, Operating Systems, Security, Algorithms and Data Structures, and Networking. Node is a great candidate to use to learn these things, and honestly, it doesn’t really matter what you pick to learn these, just master them with whatever you feel most comfortable with, and I promise you if later you want to move to another back end technology, it’ll be a cinch! Best Regards
@viridianite
@viridianite Год назад
Rust will certainly take over. The laws of physics are being written in it as we speak.
@kiranmnrao1914
@kiranmnrao1914 Год назад
I think you forgot to remove the property from the master object when we call myE.once(). removeListener (eventName, fn) { let lis = this.listeners[eventName]; if (!lis) return this; for(let i = 0; i
Далее
TypeScript: Building a better EventEmitter
12:56
Просмотров 10 тыс.
Ajdarlar...😅 QVZ 2024
00:39
Просмотров 225 тыс.
STOP Using Classes In JavaScript | Prime Reacts
14:02
Просмотров 234 тыс.
Node.js "Event Emitters" Explained
9:50
Просмотров 8 тыс.
Node.js is a serious thing now… (2023)
8:18
Просмотров 642 тыс.
Concurrency vs Parallelism in Node.js
7:47
Просмотров 41 тыс.
The Node.js Event Loop: Not So Single Threaded
31:54
Просмотров 166 тыс.
Scaling your Node.js app using the "cluster" module
13:44