This JavaScript pattern offers:
- One object to rule them all!
- No third complex or semi-complex libraries to manage the app state.
- Very intuitive and easy-to-learn curve, compare to thick boilerplates of other libraries.
- Works in any framework that uses JavaScript.
- 28 JavaScript lines to deliver a fully functional state management tool.
- There are no possible memory leaks on subscriptions, because in emit() is implemented an automatic check for unmounted Components. While in such cases emit() executes another branch, which simply removes the corresponding component from core.subscribers object.
A detailed explanation can be found in a Medium article here. While the demo is hosted in surge here.