Build a Reactive Map Data Structure That Emits Change Events on Mutations
Create a custom Map-like class that extends or wraps the native ES6 Map and emits events whenever entries are set, deleted, or cleared. Support addEventListener('set', cb), addEventListener('delete', cb), and addEventListener('clear', cb) with the affected key and value passed to the callback. Also support removeEventListener and one-time listeners via once(). This is the observable data store pattern used in MobX, Vue's reactive Map, and client-side state engines.