How To Make Your Own JavaScript Events

  Рет қаралды 75,637

Web Dev Simplified

Web Dev Simplified

Күн бұрын

JavaScript has tons of different events that you can listen to, but you can also create your own custom event for any use case you can think of. Best of all it is incredibly easy to create a custom event in JavaScript. These events are great for implementing things like touch based gestures, and even communicating across your application.
📚 Materials/References:
Event Listener Video: • Learn JavaScript Event...
Event Listener Article: blog.webdevsimplified.com/202...
Custom Events Article: blog.webdevsimplified.com/202...
🌎 Find Me Here:
My Blog: blog.webdevsimplified.com
My Courses: courses.webdevsimplified.com
Patreon: / webdevsimplified
Twitter: / devsimplified
Discord: / discord
GitHub: github.com/WebDevSimplified
CodePen: codepen.io/WebDevSimplified
⏱️ Timestamps:
00:00 - Introduction
00:40 - Basic Custom Events
02:43 - Custom Event Options
05:51 - Passing Data To Custom Events
06:48 - Double Click Example
#CustomJSEvents #WDS #JavaScript

Пікірлер: 57
@christopherholt3782
@christopherholt3782 2 жыл бұрын
Been watching you for years now. You're such a good instructor, I attribute a lot of my knowledge to you, thank you so much!
@infinitepurelive
@infinitepurelive 2 жыл бұрын
dude your content is always just awesome, I can't wait to use this in a project
@ZacharyBetz
@ZacharyBetz 7 ай бұрын
I’ve been doing web dev for years and just learned about custom events. Thank you for sharing 💪
@astec9051
@astec9051 Жыл бұрын
U are legit the best JS youtuber ever, keep doing your content because u are just the definition of perfect !
@ugljesavojvodic3384
@ugljesavojvodic3384 2 жыл бұрын
Nice video 👍 I like that you cover subjects like this (rare subjects). Others have videos that are mostly same and similar with other youtubers.
@andianwar5784
@andianwar5784 2 жыл бұрын
Thanks for speaking clearly, as an Indonesian which i dont speak native english, your video is really helpful, thank you
@LePhenixGD
@LePhenixGD 7 ай бұрын
Using custom events in conjunction with web components is the cream of the top!
@ChrisAthanas
@ChrisAthanas 2 жыл бұрын
Such a clear explanation. Kudos.
@kakakakaka7955
@kakakakaka7955 11 ай бұрын
For the use cases I would add a situation when you want to integrate React UI and a game engine. Using custom events you can make the game engine and React UI communicate and share data between each other.
@mqkDURAN
@mqkDURAN Жыл бұрын
I don't know where you work but they are lucky to have you.
@banegool
@banegool 2 жыл бұрын
Thanks!
@WebDevSimplified
@WebDevSimplified 2 жыл бұрын
Thank you for the support!
@smtp_yurzx
@smtp_yurzx 2 жыл бұрын
You should make a tutorial on how you keep your hair looking so good!
@montebont
@montebont Жыл бұрын
Nice one - thanks. But I wonder about the use case. I think you mentioned decoupling different parts of an app which makes sense. But wouldn't a simple PUB/SUB mechanism (essentially a MAP where the key is the event "name" and the value is an array of handlers) be more efficient?
@c__beck
@c__beck 2 жыл бұрын
Will there be a follow-up video about using events in Node,js?
@Johnny-rf4iu
@Johnny-rf4iu 2 жыл бұрын
+1
@hpgildwel
@hpgildwel 2 жыл бұрын
NodeJS events are well documented if you can't wait
@sriramiyer9840
@sriramiyer9840 2 жыл бұрын
Do a follow-up video on how to do this with typescript's types please
@radezzientertainment501
@radezzientertainment501 Жыл бұрын
lovely vid
@aryanjainascanio3388
@aryanjainascanio3388 2 жыл бұрын
Hi, How do you upload a document publicly for everyone like you did with the 2048?
@Marcosmapf
@Marcosmapf 2 жыл бұрын
when would a composed event be more useful than a postMessage api call?
@7heMech
@7heMech 2 жыл бұрын
Is this only for the web, or it works for nodejs aswell?
@navjotsingh2457
@navjotsingh2457 2 жыл бұрын
Ty
@Mickey_McD
@Mickey_McD 2 жыл бұрын
I used this in conjunction with a Promise; I had the Promise resolve when my custom event was generated.
@Yoreni
@Yoreni Жыл бұрын
can you put your own event data in the dispatch event function
@fraidoonhu9284
@fraidoonhu9284 2 жыл бұрын
Great
@Primadex
@Primadex 8 ай бұрын
Weldone boss, pls can you make a video on how to set isTrusted=true
@stoneshou
@stoneshou 2 жыл бұрын
Please do some explanation on shadow DOM!
@stoncjoesperanto8632
@stoncjoesperanto8632 2 жыл бұрын
Hard to read, text is too small (whereas there's a lot of empty room in the screen)... :-(
@TheScriptingLegend
@TheScriptingLegend 2 жыл бұрын
Waiting for how to make your own JavaScript
@yoskokleng3658
@yoskokleng3658 7 ай бұрын
Sir, How to detect closed tab browser by javascript event? not reload ( i want to do something when user try to closed tab or exist browser directly without logout my web application ). thanks 🙏
@BGdev305
@BGdev305 Жыл бұрын
@WebDevSimplified you never showed how to "communicate between 2 different parts of the application"?
@mznunaya
@mznunaya 2 жыл бұрын
I love you Kyle
@roshanlalsahu7846
@roshanlalsahu7846 2 жыл бұрын
can u please make video on shadow DOM
@mojlbhr1480
@mojlbhr1480 2 жыл бұрын
Great! but the example not enough for what is the use case.
@tolotrarabefaly1333
@tolotrarabefaly1333 2 жыл бұрын
What about EventEmitter?
@AbhishekGupta-zf4em
@AbhishekGupta-zf4em 2 жыл бұрын
Bro you got amazing hair :)
@be2wa
@be2wa 2 жыл бұрын
Isn't there a native dblclick event already?
@Laura69
@Laura69 2 жыл бұрын
It is just an example showing how it could be implemented.
@rotterwane426
@rotterwane426 2 жыл бұрын
Klye, would you prepare for angular tutorial
@MrCC-hx8xr
@MrCC-hx8xr 2 жыл бұрын
learn vue or react, angular will die
2 жыл бұрын
More appropriate name would probably be 'creating DOM events'. Technically this is not connected to Javascript.
@thesneakyturtel
@thesneakyturtel 2 жыл бұрын
:thumbsup:
@charlesscholton5252
@charlesscholton5252 Ай бұрын
Not seeing the ; at the end of lines and the reliance upon ASI is sort of traumatic for me. Lol
@igu642
@igu642 7 ай бұрын
❤❤❤❤
@JEsterCW
@JEsterCW 2 жыл бұрын
Sheeeesh
@zainou8460
@zainou8460 2 жыл бұрын
Why would someone need a custom event ?
@almogosheriko
@almogosheriko 2 жыл бұрын
There might be something that you want events to trigger for that aren't covered in JS's built in events. It really depends on what you need to do for your project. The possibilities are endless.
@SteveUrlz
@SteveUrlz Жыл бұрын
no offense or anything, I was just wondering why do you misspell often. I see my CTO coding in the same style and was curious if this is dyslexia or just writing fast
@tognolibsas
@tognolibsas 6 ай бұрын
The sound is too low man
@anandpawar2096
@anandpawar2096 2 жыл бұрын
100 like
@suelingsusu1339
@suelingsusu1339 2 жыл бұрын
👏👏👏👏🙏🙏🙏🙏🙏👌👌👌👌👌🖖🖖🖖🖖🖖🖖🖖
@Dream-Web
@Dream-Web 2 жыл бұрын
276th viewer
@Nick-dt7ut
@Nick-dt7ut 2 жыл бұрын
Second comment
@sarrthecode
@sarrthecode 2 жыл бұрын
First comment
@mehrdad1068
@mehrdad1068 2 жыл бұрын
Please make tutorial for like_unlike_dislike_undislike_comment_share_replay_save_unsave 🙏🙏🌱🌻
@CodeAProgram
@CodeAProgram 2 жыл бұрын
Learn new
How To Create Your Own Implementation Of JavaScript Promises
33:34
Web Dev Simplified
Рет қаралды 98 М.
Learn JavaScript Event Listeners In 18 Minutes
18:03
Web Dev Simplified
Рет қаралды 562 М.
How To Choose Ramen Date Night 🍜
00:58
Jojo Sim
Рет қаралды 60 МЛН
Normal vs Smokers !! 😱😱😱
00:12
Tibo InShape
Рет қаралды 97 МЛН
Uma Ki Super Power To Dekho 😂
00:15
Uma Bai
Рет қаралды 56 МЛН
This Is Unbelievably Powerful
11:15
Web Dev Simplified
Рет қаралды 98 М.
How To Build Your First TypeScript Project - TODO List Application
28:30
Web Dev Simplified
Рет қаралды 233 М.
Learn JavaScript Touch Events In 17 Minutes
17:45
Web Dev Simplified
Рет қаралды 106 М.
Имитируем события в JavaScript. DispatchEvent
18:53
WebDev с нуля. Канал Алекса Лущенко
Рет қаралды 16 М.
Custom Events in Javascript (CustomEvent)
5:55
dcode
Рет қаралды 48 М.
Stop Wasting Your Time - Use These 16 JS Utility Functions Instead
17:10
Web Dev Simplified
Рет қаралды 72 М.
10 Tailwind Classes I Wish I Knew Earlier
13:31
Web Dev Simplified
Рет қаралды 154 М.
How To Choose Ramen Date Night 🍜
00:58
Jojo Sim
Рет қаралды 60 МЛН