摘要:
// 被观察者 class Subject { constructor(name) { this.name = name; // 存放所有观察者 this.observers = []; // 心情状态 this.mood = "心情很美丽"; } // 接受观察者方法 attach(observe 阅读全文
摘要:
let fs = require('fs'); // 发布订阅 发布和订阅没关系 中间通过数组进行关联 function Events() { this.callbacks = []; this.results = []; } // 订阅 Events.prototype.on = function 阅读全文