test页首Html代码test

Observer Pattern

P173

Listing 7-6.  The observer pattern

 

            // If an event by the supplied name has not already been subscribed to, create an
            // array property named after the event name within the events object to store
            // functions to be called at a later time when the event by that name is triggered
            //如果所提供的名称(第一个参数)对应的事件还没有被订阅,则在events对象中添加一个属性,该属性的数据类型为数组,该属性的名称为该事件的名称,以此属性来保存在稍后该名称的事件被触发时所要调用的函数。
            if (!events.hasOwnProperty(eventName)) {
                events[eventName] = [];
            }

posted @ 2015-02-23 21:19  向着目标稳步前行  阅读(123)  评论(0编辑  收藏  举报

test页脚Html代码test