15.01 - sellsian approach.js
来自「JS设计模式源代码」· JavaScript 代码 · 共 28 行
JS
28 行
/* From http://pluralsight.com/blogs/dbox/archive/2007/01/24/45864.aspx *//* * Publishers are in charge of "publishing" i.e. creating the event. * They're also in charge of "notifying" (firing the event).*/var Publisher = new Observable;/* * Subscribers basically... "subscribe" (or listen). * Once they've been "notified" their callback functions are invoked.*/var Subscriber = function(news) { // news delivered directly to my front porch};Publisher.subscribeCustomer(Subscriber);/* * Deliver a paper: * sends out the news to all subscribers.*/Publisher.deliver('extre, extre, read all about it');/* * That customer forgot to pay his bill.*/Publisher.unSubscribeCustomer(Subscriber);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?