Keeping singletons distinct doesn't seem very useful and only disperses the app's dependencies unnecessarily. They're primary distinction from the rest of the code is that they're instantiated once and shared globally. If the dependencies cannot be passed by parameter, consolidating them seems preferable.
Acceptance criteria
- Move singletons to one file, singleton.js.
- Lazily initialize singletons on access. Maybe something like:
/** @prop {OO.EventEmitter} [_eventBus] */ class Singleton { /** @return {OO.EventEmitter} */ eventBus() { if ( !this._eventBus ) this._eventBus = new OO.EventEmitter(); return this._eventBus; }, moduleLoader() { ... } }
- State should be resetable by tests if that's useful.
- References in MobileFrontend and MinervaNeue are updated.