Тёмный

How The Observer Pattern Works 

MattStopaDev
Подписаться 1,7 тыс.
Просмотров 57 тыс.
50% 1

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

 

29 окт 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 37   
@chew
@chew 7 лет назад
Thanks for this. Another analogy I thought of while watching was a person receiving a text or email. Rather than constantly checking your messages for a reply to a text, your phone has this neat functionality where is vibrates or makes a noise when the you receive a text.
@pelumiolaoye9680
@pelumiolaoye9680 3 года назад
More dicy if you have multiple devices...They all get the notification simultaneously.
@benedictuyioghosa5667
@benedictuyioghosa5667 4 года назад
Best analogy so far. Thanks
@OlgaFB1
@OlgaFB1 2 года назад
thank you! very clear, short and to the point!
@thepowercareers
@thepowercareers 5 лет назад
Thanks... Understood it well with examples.... I hope you make more such videos...
@peijiaguo469
@peijiaguo469 2 года назад
A "thank you so much" from 7 years later
@kieranthart4527
@kieranthart4527 4 года назад
Really great explanation, thankyou!
@MattStopaDev
@MattStopaDev 4 года назад
Awesome! Thanks for the feedback
@nidhalabidi69
@nidhalabidi69 3 года назад
I loved the analogy a lot , thank you !
@kmk69
@kmk69 4 года назад
this taught me a lot
@MattStopaDev
@MattStopaDev 4 года назад
Awesome great!
@colinmcb8316
@colinmcb8316 10 лет назад
Thank you so much for these videos they are awesome. Keep going!
@AfroDanceWithZeAmazingBreezy
@AfroDanceWithZeAmazingBreezy 5 лет назад
at least i learned something so one thumb up
@BadriNathJK
@BadriNathJK 8 лет назад
read GoF book couldnt get it and then i saw your video got it in 5 mins. Excellent video
@mattstopa9436
@mattstopa9436 4 года назад
Glad to hear it. GOF is tough to get through lol
@sjwonka8412
@sjwonka8412 3 года назад
Starkes Video! :D War echt hilfreich ;)
@ForgottenKnight1
@ForgottenKnight1 8 лет назад
You can have 2 implementations. One is where a subject broadcasts ( or "pushes" ) to all its observers its changed state, the other is when observers ask ( "pull") from the subjects its state when needed. Where one compromises reuse, the other is less efficient ( more calls ). In our case, the news guy(subject) can be asked by the news agencies(the observers) about his availability(state), so they can send him the requirements for the next news. On the other hand, the news guy(subject) can have multiple news agencies(observers) registered in a list, and if he finds some news, he will broadcast ( send ) to the agencies those news ( state ). This pattern can also be extended even more, where you have multiple news guys, communicating back and forth with multiple news agencies and providing different types of news, depending on different types of availability from the agencies.
@benedictuyioghosa5667
@benedictuyioghosa5667 4 года назад
Nice explanation
@stevelitt
@stevelitt 4 года назад
well done, thanks
@AshishBurnwal
@AshishBurnwal 6 лет назад
Great Example to understand it, Thank you so much
@penggunaphp7297
@penggunaphp7297 6 лет назад
Finally i got the idea with this video. Thanks...
@LuaneCarolineAquinoCavalcanti
@LuaneCarolineAquinoCavalcanti 4 года назад
Finally I understood, thanks!
@martopad
@martopad 6 лет назад
Thanks man, this video is very helpful
@JannisAdmek
@JannisAdmek 3 года назад
this is really good!
@alecc8231
@alecc8231 3 года назад
The most realistic example from a few explanations I've seen. But, you've never declared a 'listener' in your example. In this case the listener could be an ui form Label that implements an IObserver interface. IObserver Interface could have a single method Notify(string text). Then Notify method will take changes from the Text box and displays modified value of the text box. Like this: //Declarations interface IObserver { Notify(string text); } class Label : IObserver(), FormLabel { Notify(string text) { var IntValue = (int)text; Label.value.text = intValue*0.05; //displays 5% of text box value. } //FormLabel code here. } class TextBox : IObservable : FormTextBox { void Add(IObserver observer) { myObservers.Add (observer); } void Remove(IObserver observer) { myObservers.Remove(observer); } void OnChange() { ForEach(IObserver obsv in myObservers) { obsv.Notify(myNewText); } } } //initialization: TextBox txtBox1 = new TextBox(); textBox1.Add(label1); // now changes in the text box will trigger the notifications in observers. in this case a Label.
@Joshuavmeer
@Joshuavmeer 8 лет назад
thanks, very helpful.
@chryssoulable
@chryssoulable 10 лет назад
Nice analytic work on your part ;) . That's for the new video.
@pmbhagat077
@pmbhagat077 6 лет назад
this sounds familiar. seems like android uses observer pattern. in android we register ActionListener with a button. I guess this makes the ActionListeners "news bureaus". when event onClick takes place, button notifies the actionListener by calling it back using their callback function. this makes button "reporter".
@rnilu86
@rnilu86 7 лет назад
Does Angular js $scope.$watch use the same pattern?
@maikforte757
@maikforte757 7 лет назад
I'd like to hear this from the experienced too. +1
@mahammednoorhussinali7474
@mahammednoorhussinali7474 6 лет назад
Thank u for the explanation but i hoped if u went through code a bit more. Thnks anyway
@Meskalin_
@Meskalin_ 2 года назад
hi matt
@MeshTheSnake
@MeshTheSnake 5 лет назад
literally on the edge of greatest video if that code example would've been in Java, C# or something else.
@mattstopa9436
@mattstopa9436 4 года назад
What' the fun in that? :-p
@davidblack4095
@davidblack4095 3 года назад
i realy want to like but the number of like is so interest to me and i wouldnt break that. 😎😎 666
@DevSage
@DevSage 4 года назад
I made a video on the Observer pattern
Далее
The observer pattern (with Java example)
16:02
Просмотров 34 тыс.
PubSub Design Pattern in JS
23:23
Просмотров 29 тыс.
Observer Pattern - Design Patterns (ep 2)
49:47
Просмотров 568 тыс.
Tutorial: The Observer Pattern in Python
21:20
Просмотров 39 тыс.
5 Design Patterns Every Engineer Should Know
11:51
Просмотров 940 тыс.
10 Design Patterns Explained in 10 Minutes
11:04
Просмотров 2,3 млн
Observer Pattern Tutorial
15:40
Просмотров 6 тыс.
Observer Design Pattern in Java
14:34
Просмотров 173 тыс.
Design Patterns: Observer and Publish-Subscribe
18:18