Search code examples
reactjsmodeleventemitter

Should my in-browser data models be singletons?


I am doing a React app and I want to do my in memory data models with es6 modules and EventEmitter. Wondering if it is recommended to use a singleton.

Also I heard that this event emitter is the one to use.


Solution

  • The answer is yes! Models in a module based front end should be singletons! Otherwise their data is not persistent across the various imports!