今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Observer pattern
- [Instructor] The Observer pattern is one where we maintain a list of objects based on events, and is typically done with updating data based on these events. It is implemented for example, with the subscribe methods in MeteorJS. Let's take a look at code to see how it looks like. So if you go into the exercise files, and then in chapter 4, and then video 04_02, you can drag and drop this folder directly into visuals to do code. And that's a good example of the observer pattern. So right now we created a class, so with a constructor we created that class for car. And inside of it we have a gas element, and we have a setter and then we have an observer. So basically we're able to set what is the gas level for that car, and then we can observe what is the level of that gas. There's a couple of functions here that allows us to register and then un-register an observer and then notify what is the gas level…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
(已锁定)
What are behavioral patterns?1 分钟 4 秒
-
(已锁定)
Observer pattern2 分钟 36 秒
-
(已锁定)
State pattern3 分钟 6 秒
-
(已锁定)
Chain of responsibility1 分钟 30 秒
-
(已锁定)
Iterator pattern3 分钟 44 秒
-
(已锁定)
Strategy pattern1 分钟 36 秒
-
(已锁定)
Memento pattern53 秒
-
(已锁定)
Mediator pattern1 分钟 32 秒
-
(已锁定)
Command pattern2 分钟 24 秒
-
(已锁定)
-