Pub/sub bus cho phép micro-frontends communicate mà không cần direct coupling.
js
const bus = {
subs: {},
subscribe(event, fn) {
(this.subs[event] ||= []).push(fn);
return () => { this.subs[event] = this.subs[event].filter(f => f !== fn); };
},
publish(event, data) { this.subs[event]?.forEach(fn => fn(data)); }
};Dùng cho cross-app communication.
Thêm: typed events, wildcard, once listener.