发布订阅

核心类

var Center=function(){

this.beNoticeList=[];

}

Center.prototype.add=function(obj){

this.beNoticeList.push(obj);

}

 

Center.prototype.notice=function(){

for(var item in this.beNoticeList)
{

this.beNoticeList[item].update();

}

}

var user1={update:function(){

console.log("this is user1")

}}

var user2={update:function(){

console.log("this is user2")

}}

var  dep=new Center();

dep.add(user1);

dep.add(user2);

dep.update();

c

onsole.log("this is user1")

posted on 2018-08-29 10:40  水寒03  阅读(95)  评论(0编辑  收藏  举报

导航