今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Implementing observers
- [Instructor] In the last lesson, we introduced the observer design pattern. We also showed how we could implement the observer design pattern and have observer objects like shoppers and malls listen to observable objects like the store. In this lesson, we're actually going to write the code to make the observer design pattern work in our example. So, I'm in the exercise files under chapter four, under chapter four lesson nine within the star folder, and we can see that we have the changes that we just made to our index.js file. So, let's go ahead and first make the changes that we need to make to the observers, so I'll start with the shopper. And in order for this to work, the shopper's going to have to implement a method that the store can call. So, we'll call notify, and it will give us the store name and the discount. So, whenever a shopper has been notified of a sale, we'll just go ahead and log that information to…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
(已锁定)
Chain of responsibility4 分钟 42 秒
-
(已锁定)
Implementing the storage class6 分钟 22 秒
-
(已锁定)
The Command pattern4 分钟 47 秒
-
(已锁定)
Implementing commands4 分钟 59 秒
-
(已锁定)
Improving the conductor6 分钟 38 秒
-
(已锁定)
The Iterator pattern4 分钟 5 秒
-
(已锁定)
Implementing iterators4 分钟 59 秒
-
(已锁定)
The Observer pattern4 分钟 19 秒
-
(已锁定)
Implementing observers2 分钟 48 秒
-
(已锁定)
The Strategy pattern4 分钟 25 秒
-
(已锁定)
Implementing strategies9 分钟 36 秒
-
(已锁定)
-