Nest.js | Events & Task Scheduling Tutorial
Vložit
- čas přidán 9. 07. 2024
- In this video, we learn about how to decouple functionality in our application leading to faster backend services and cleaner code.
Github Repo: github.com/mguay22/nestjs-eve...
Nest.js Events: docs.nestjs.com/techniques/ev...
Nest.js Tasks: docs.nestjs.com/techniques/ta...
Timestamps
00:00:00 Project Setup
00:03:50 Events
00:09:17 Task Scheduling
Get my highly-rated Udemy courses at a discount here: michaelguay.dev/udemy/ - Věda a technologie
Get my highly-rated Udemy courses at a discount here: michaelguay.dev/udemy/
I just subscribed to your channel because of this, man. I love it.
Thanks! Great as always!
Love how you explain. I just started out with nestjs last week and watching this video shows me how much I can improve. Thanks for the awesome content.
Cool! Thanx a lot, bro! Info as always useful!!
Nestjs is so cool !! My company has a plan on switching to nestjs. Thanks for these contents man!
Thank you for making actually useful videos and not just how to create a todo or something.
Great video, Michael! One of the very few channels making such informative videos on NestJS. Looking forward to your next one - the end to end guide on micro-services using NestJS.
I hope you are planning to include a tutorial on how to deploy them on AWS. 🤞😇
This was a really good video
You are best backend developer bro💪🤩
Omg. Its so good video!
Impressive tutorial 😊
Subscribed ✅
You're the best bro. I love your videos
I appreciate that!
Thank you for this amazing video. Quick question Michael, how should one decide whether or not to use Events or Queues?
Good!
Thanks bro
Great video Michael! Trying to reproduce the events in one of my projects, I encountered a problem... The event is only emitted once, but the OnEvent listener is firing twice. Any idea why??
Can I use events for notification like while user fill up the form that will notify the admin through event?
Hey Michael, really great video!
One quick question: Can the event be listened from any module of the app or only inside the class where you emit it from?
Keep up the amazing NestJS videos!!
We can listen from anywhere. It can even be from messages produced from a different app!
@@mguay whaat?! how does it do that? Do you have any resources about it?
Also, do you happen to have a community place like a discord server or anything like that?
Please tell me: what theme are you using? I love those colors
Did it hurt when you fall? I'm talking about that time god sent you to the earth from the sky, CUZ YOU ARE A GODDAMN ANGLE!
I wondering how we can prevent overlapping cron? I search so many topic on SO but still can't find a solution :(
Hi Michael, I was trying to implement a functionality with events, to run several operations in a transaction, but I don't know how to handle it, so everything is rolled back if any of the operations fail. would you mind giving an advice on how to do that kind of behaviour?
This is amazing Michael! regarding scaling and fault tolerance, as the schedule registry is in memory, how would you handle distributing this? would you consider making a vid about this?
Hey thanks. The recommended approach for distributing this is to use something like BullMQ. Check out my channel for a video on that.
github.com/nestjs/schedule/issues/28
Awesome content! Btw which font do you use?
Material!
Cool stuff. Is `Emit` stuff more like a message-queue stuff? You know, celery in Python.
I got one question, you said that this event in async mode is send to the separate thread. I think it is not true. Js is single threaded, also node (without some internal apis from Libuv) but the EventEmitter is build in javascript and works in sync manner. I know that nest js is using event emmiter 2 that is async aware but anyway it is not handled in separate thread. If Im wrong please correct me, Im trying to solve the misery how this emitter works in Nest and the async manner is purely described even in official event emmiter 2 docs.
in case where use is registered, and then a gift is sent to the user, but after that we want to make some update on the user, so how do we send data back to the function from where the event is dispatched? any ideas ?
Have you tried emitAsync?
I am a php developer (laravel) and i have to admit it, i was pretty skeptical about node (not this framework, node in general). It seems cool and your video are very clear. What i really don't like is that the cose is quite confusing. In controller you can have http handler (post, get,...) and events handler. I think this can cause messy code very faster than other framework, and the unmessy behavior is demanded to the developer.
😂.. well, it's opinionated.. every framework has its downsides.. a downside for me might be an advantage for you
@@samuelvalentine7846 attitude says all!
Any tips on managing cron like processes on multiple instances? been using bull repeatable jobs but it's feels a bit janky.
I plan on making a video in the future. I would think Bull would be a good candidate since it can be backed by a distributed Redis store, but I haven’t tried it yet so maybe it’s not so great like you point out.
@@mguay It works ok it just doesn't have the great dev UX those @Cron decorators. Thanks for all the video's found the ones you did on testing on nest.js really helpful!
The Bull repeatable jobs integration is definitely janky, but it does work
I guess it depends on the deployment.
If it is a kubernetes stack you could simply make a cronjob which will make a fetch and the load balancer will make sure it only is executed once.
can you make a video on queue with bulljs
+1 cmon buddy
any different when comparing to use kafka
They can both be used to implement an event-driven approach, but i think Kafka is more sensible for processing large quantities of messages for performance reasons - as it allows a distrubted system, and other reasons like fault tolerance, etc.
What if container in cloud gets killed ?
Great question. Check my latest video on BullMQ
👇 𝔭𝔯𝔬𝔪𝔬𝔰𝔪