Node JS Tutorial for Beginners #8 - The Node Event Emitter

Node JS Tutorial for Beginners #8 - The Node Event Emitter

Net Ninja

8 лет назад

291,759 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Kostiantyn Karzhanov
Kostiantyn Karzhanov - 05.10.2023 04:03

Thank you! Very well explained! 💛

Ответить
museum exhibition of intense fixations
museum exhibition of intense fixations - 26.07.2023 16:13

old but gold! for me it was the jquary example. thanks a lot ninja master. 2023 and still the best explanation about eventemitter🐱‍👤
btw this can be updated in a new video ES6 style!

Ответить
ARTICO
ARTICO - 11.01.2023 20:28

2023 here and node 18 , it say to me that .inherist is discurage

Ответить
Crimson Beast
Crimson Beast - 15.07.2022 18:28

theme name 🥺.?

Ответить
ifraz I
ifraz I - 11.05.2022 11:36

Hi, This session, any example, for what is this normally used for. util.inherits(Person,events.EventEmitter); and other below codes.
Thx

Ответить
zy T
zy T - 25.03.2022 22:45

thanks for this session, as a newbie, Im still confused about the emitter. might need to study harder, thanks Ninja.

Ответить
Master Hans
Master Hans - 18.02.2022 10:13

I need to watch all your videos xD

Ответить
Alex G
Alex G - 03.02.2022 16:26

thx

Ответить
Shaista Kamran
Shaista Kamran - 15.11.2021 23:45

Boss this could be done without an Array as well.

Ответить
there hi
there hi - 04.11.2021 02:44

here by 2021.
what version of ECMA script is this code belong to?
wonder know that the util is mandatory structure due to get some inheritances.
bcoz some comments say it has changed OR replacement code is exist.
BTW thanks much.

Ответить
Sanskar Khunt
Sanskar Khunt - 04.10.2021 13:08

usage of  "util. inherits" discouraged. Please use the ES6  and keywords to get language level inheritance support. Also note that the two styles are semantically incompatible.

Ответить
Vatsal Mehta
Vatsal Mehta - 22.06.2021 17:45

Its super awesome /easy to understand and ultra time saving❤️❤️🔥🔥

Ответить
Mohamed Elsayed
Mohamed Elsayed - 13.06.2021 02:59

Thank you

Ответить
Sumedh Sen
Sumedh Sen - 23.04.2021 05:43

PSA:
var Person = (name) => {......} wont work in this case. it has to be the way it is shown in the video.
Can anyone explain why is it so?

Ответить
xiaocai7
xiaocai7 - 09.04.2021 12:09

Totally lost

Ответить
pankaj
pankaj - 16.03.2021 18:12

// guys ignore this comment
// brief notes
const events = require('events");

var emitterObj = new events.EventEmitter(); // EventEmitter is object in event module

// creating an event
emitterObj.on('myEvent1', function(msg){
console.log(mssg);
} ); // function is executed when myEvent1 is emitted

emitterObj.emit('myEvent', 'argument to function' ); // after event name onwards rest are passed to function as param

Ответить
Kyoontol
Kyoontol - 16.12.2020 06:11

I really enjoyed watching your video. but here I want to ask, why do you use the util module instead of just using classes? is there a difference in usage?. and by watching your video I am very grateful that your video gave me enough understanding for emitter event.

Ответить
Adie Mar
Adie Mar - 12.11.2020 15:01

thankyou sir. it's a big help to us.

Ответить
Zaid z
Zaid z - 19.10.2020 02:17

This is new to me
shouldn't Person extend another class like a normal peaceful class
why using util.inherit
edit after Googling
u can they are the same
use this instead
class Person extends EventEmitter {
    constructor(name) {
        super();
        this.name = name;
    }
}

Ответить
ninja-gh
ninja-gh - 06.10.2020 11:18

You deserve more than a million subscriber man.

Ответить
questionable0899
questionable0899 - 02.10.2020 22:12

Good explanation, many thanks

Ответить
Srinath Kamath
Srinath Kamath - 09.08.2020 11:08

Hey I'm getting this error while trying to convert to ES6 as recommended by VSCode.
var events = require('events') converting this to import { EventEmitter } from 'events';

Error
import { events } from "events";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1047:16)
at Module._compile (internal/modules/cjs/loader.js:1097:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47

Why doesn't it work when converted to EcmaScript6?

Ответить
salma yossef
salma yossef - 10.07.2020 20:27

myEmmitter.On('someEvent',function(msg){
console.log(msg);
});
please some one tell me whats wrong in this function cause it doesn't work with me

Ответить
hyperborean72
hyperborean72 - 10.07.2020 17:31

I did not notice when we imported 'events' and 'utils', and where they are described (what .json)?

Ответить
KARAN GUPTA
KARAN GUPTA - 06.07.2020 13:35

his accent is hard to get.

Ответить
William94
William94 - 04.07.2020 18:05

What's is the difference between utils.inherit and extends of ES6?

Ответить
anotherboredperson
anotherboredperson - 23.06.2020 17:15

ok i got fuckin lost

Ответить
Xavier Alejandro
Xavier Alejandro - 09.06.2020 01:17

This is the first video in the series that really made me think to follow along the code and know what's going on.. I missed this feeling

Ответить
RonnieSunshine
RonnieSunshine - 21.05.2020 05:31

Great tutorial but I can't imagine a single practical application for this. I could do the exact same thing with less code using a method. And it would also make more sense to more developers because its not using proprietary features.

Ответить
中二病子
中二病子 - 29.04.2020 13:10

It's like Classes and Objects in Python.

Ответить
Rudra Patil
Rudra Patil - 24.04.2020 11:43

Your videos are great

Ответить
nayr Y
nayr Y - 14.04.2020 08:33

the only info useful is the first 3 clips

Ответить
Lorenzo Simon De Riso
Lorenzo Simon De Riso - 10.04.2020 13:01

you are the best

Ответить
Gal
Gal - 29.03.2020 22:05

This was a bit unclear to me.
1. What is the use of the events? I could have done that in a function called "speak" that accepts a message. What's the advantage of using an event here?
2. Inside the forEach, why do we need a function (the arg of the forEach), can't we just do a forEach that does the "on('speak'..." for each of the persons without using a function? Hard to explain..I hope you understood.

Ответить
The Wanderer
The Wanderer - 19.03.2020 12:45

update ur node tutorial sensei

Ответить
Shravan Gourishetty
Shravan Gourishetty - 24.12.2019 10:03

the function adder is not working to add numbers which u have explained in 7th video

Ответить
Youssef Mohamed
Youssef Mohamed - 06.12.2019 11:02

You have one of the best NodeJS educational material for beginners. Your videos are organized and to the point. I definitely would recommend it.

Ответить
Anastasia Ionas
Anastasia Ionas - 01.12.2019 11:27

"let's go ahead and make some people" 😂

Ответить
Personal Chao yu
Personal Chao yu - 15.11.2019 13:23

Thanks .

Ответить
PHOTON
PHOTON - 12.11.2019 08:24

i am soo confused on what anything does...

Ответить
Roronoa_D_Law
Roronoa_D_Law - 10.10.2019 17:36

you lost me when you used this in a function xD this is to be used in a class right ?

Ответить