Observer (TypeScript Design Patterns)

  Рет қаралды 29,368

Simply Explained

Simply Explained

Күн бұрын

Пікірлер: 40
@supermetan3571
@supermetan3571 7 жыл бұрын
hands down, best tutorials on youtube, keep it up. You are an impressive teacher, very easy to follow
@simplyexplained
@simplyexplained 7 жыл бұрын
Thanks a lot!
@mohammadmohabsarhan3961
@mohammadmohabsarhan3961 4 ай бұрын
I must say, whoever invented this is just a genius, Thanks for the tutorial.
@chikamichi
@chikamichi 5 жыл бұрын
Beware, in this video Xavier calls what's observed, a Subject. Yet the proper naming is "Observable". A Subject is an entity that may act as *both* an Observable and an Observer. It's the building block used in implementing Pub/Sub systems (think chat app, typically).
@ojuliomiguel
@ojuliomiguel 4 жыл бұрын
Good!
@jananpatel9030
@jananpatel9030 Жыл бұрын
7:47 why are we saying weatherStation.registerAObserver(this). Why aren't we using this.subject? This is the only part that confused me
@iqbalibrahim4713
@iqbalibrahim4713 2 жыл бұрын
Thank you for the video, before this I saw a video about observer pattern elsewhere but was not able to understand when needed more than one observer, your video explains really well and with good examples, deserve a like and subscribe
@elijah6283
@elijah6283 2 жыл бұрын
Thank you, this is one of the best explanations of the observer design pattern implemented with TypeScript.
@raj.blazers
@raj.blazers 6 жыл бұрын
Tutorials are damn good. Please post more design patterns.
@muliaarifandynasution525
@muliaarifandynasution525 6 жыл бұрын
Awesome! I hope there are more videos about design patterns like this.
@hakart411
@hakart411 5 жыл бұрын
thanks for your great tutorials there is one tiny problem in 'removeObserver' method . actually the problem is for 'splice' method and this is it : if passed observer to removeObserver method does not exist in the observers array the index become -1. then the splice remove last item from the observers array
@muhammadramzanali584
@muhammadramzanali584 3 жыл бұрын
Simply Explained! Great work!
@abdulkadirguven1173
@abdulkadirguven1173 2 жыл бұрын
Simple and clean explanation.Thank you ;)
@figidon-software
@figidon-software 6 жыл бұрын
If you are building a web-project you can also implement the observer pattern with events. Assuming you use jquery, it's as simple as: 1. Trigger the event with *$('body').trigger('weatherStation:tempChange', newTemp)* 2. Listen to event triggers with *$('body').on('weatherStation:tempChange', (e, newTemp) => { // logic to handle newTemp})* If you goto the Dev Tools you can see that youtube makes heavy use of custom events. In the Elements tab you can select an element, then see all the Event Listeners attached to it.
@Videosuser
@Videosuser 3 жыл бұрын
You are an impressive teacher,
@Antonym1978
@Antonym1978 2 жыл бұрын
Thanks for a clear explanation!
@lautaroleonhardt2600
@lautaroleonhardt2600 Жыл бұрын
Need more videos like this!
@IslamGadzhiev
@IslamGadzhiev 10 ай бұрын
Why mixing the responsibilities and logic of observability between display classes and the weather station ? That is - in the constructor in Fan and TempretureDisplay classes you do: `weatherStation.registerObserver(this);`, which means that the Observer instance inside make the Subject register it. It's wrong, i think, instead the cleaner approach would be to make the Subject register the Observer separately from the Observer being able to update based on the Subject notifications.
@ManontheBroadcast
@ManontheBroadcast 7 жыл бұрын
Crystal clear explanation .. even i am not familiar with the TypeScript syntax but just plain JS , for once i think i managed to grasp this concept ...Thanks for sharing your knowledge ...
@simplyexplained
@simplyexplained 7 жыл бұрын
+Man-on-the-Run Thanks man! I'm really trying to do my best with the videos.
@lukezzz420
@lukezzz420 4 жыл бұрын
Hi, great tutorial! One question, shouldn't you set the return value of the functions in the interfaces to void if they return nothing? Else it will have the return type any...
@webmaker6576
@webmaker6576 5 жыл бұрын
Really Deserve appreciation
@Eriksonmagno
@Eriksonmagno 3 жыл бұрын
Awesome tutorial
@H3000-v7i
@H3000-v7i 3 жыл бұрын
Why would you add a reference to the subject, in the observer?? If you the remove a observers, they will still carry unused reference. Seems like bad code to me? please correct me if im wrong.
@NagatoKamiPain
@NagatoKamiPain Жыл бұрын
can you make this video with function as well?
@a.durgadevi8052
@a.durgadevi8052 4 жыл бұрын
best tutorial . Thank you
@bhanuprathap3170
@bhanuprathap3170 4 жыл бұрын
Great tutorial
@creative-commons-videos
@creative-commons-videos 4 жыл бұрын
Can you please make a Playlist on building ORM in typescript using Object Oriented Programming, Just like Laravel Eloquent ?
@andredejager3637
@andredejager3637 3 жыл бұрын
Awesome, thank you
@hemanth6951
@hemanth6951 7 жыл бұрын
In Android also we are doing using same design pattern for callback methods
@coplain
@coplain 6 жыл бұрын
Savjee .. Thanks for the tutorial . One question though .. Imagine I have say I have large # of observers (say a billion) . Since we are using foreach loop to notify and its a O(n) operation ..by the time it reaches last observer another event happens the notify loop starts all over again.. how would we handle this scenario ? Let us say in environment like high frequency trading where trading happens in nanosecond time frames.. how can we handle this issue .. Thanks
@simplyexplained
@simplyexplained 6 жыл бұрын
Hmmm you will always have O(n) is this system. Nothing you can do about that. However you could make your observers asynchronous and distributed. Being async will allow you to quickly go through the foreach loop (since you don't have to wait for the return values). After that you spread the load among a number of computers who all work on handling a part of the observers.
@coplain
@coplain 6 жыл бұрын
Thanks
@ys1197
@ys1197 10 ай бұрын
5:40 thank u :3
@melitt6813
@melitt6813 6 жыл бұрын
good job! thanks!
@vladimirrabtsun
@vladimirrabtsun 4 жыл бұрын
Wow! Cool!
@aleksd286
@aleksd286 5 жыл бұрын
Thanks man
@hazartilirot1014
@hazartilirot1014 3 жыл бұрын
The examples are stolen from Head First Design Patters. :D
@lagiator
@lagiator 5 жыл бұрын
helpful, thanks!
Facade (TypeScript Design Patterns)
7:01
Simply Explained
Рет қаралды 19 М.
State pattern  (TypeScript Design Patterns)
12:26
Simply Explained
Рет қаралды 23 М.
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
What is the Observer Pattern? (Software Design Patterns)
21:49
Be A Better Dev
Рет қаралды 23 М.
Observer Pattern - Design Patterns (ep 2)
49:47
Christopher Okhravi
Рет қаралды 575 М.
Next Generation TypeScript | Prime Reacts
24:45
ThePrimeTime
Рет қаралды 104 М.
8 Design Patterns | Prime Reacts
22:10
ThePrimeTime
Рет қаралды 448 М.
Decorator Pattern (TypeScript Design Patterns)
9:11
Simply Explained
Рет қаралды 47 М.
Observer Pattern in JavaScript
14:29
Code with Ahsan
Рет қаралды 6 М.
Object Oriented vs Functional Programming with TypeScript
12:07
5 Design Patterns Every Engineer Should Know
11:51
Traversy Media
Рет қаралды 943 М.
TypeScript: Building a better EventEmitter
12:56
Tech Talks with Simon
Рет қаралды 11 М.
TypeScript Factory Patterns (No BS TS Series 2 Episode 1)
22:07
Jack Herrington
Рет қаралды 36 М.
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН