You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classObserver{constructor(name){this.name=name}update(value){console.log(`${this.name} has recived message from subject + ${value}`)}}classObserverList{constructor(){this.observerList=[]}add(ob){returnthis.observerList.push(ob);}remove(ob){this.observerList.filter(observer=>ob!=observer);}getList(){returnthis.observerList;}}classSubject{constructor(){this.observers=newObserverList();}addObserver(ob){this.observers.add(ob);}removeObserver(ob){this.observers.remove(ob);}notify(...args){for(letobofthis.observers.getList()){ob.update(...args)}}}
The text was updated successfully, but these errors were encountered:
订阅发布模式
观察者
The text was updated successfully, but these errors were encountered: