js实现发布订阅模式与观察者模式发布订阅模式发布订阅模式直接没有关联,可以不发布只订阅也可以只订阅不发布例:<pre<codeconstevent{_arr:,on(fn){this._arr.push(fn)},emit(){