You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd agree that it should not be a singleton. The ability to create multiple instances for multiple files is very helpful. Maybe it should be explained somewhere in the docs thou.
On another note, not sure about module.exports = new Config() but keep in mind that using ES6 modules export default new Config() is most likely not what you want. It will evaluate a single time during import and won't pick up changes to userData path, for example.
It's easy to think that it would make for a simpler API. No need to initialize it first. I thought so too at first.
But imagine if it had been a singleton:
index.js
some-component.js
Note the
undefined
. So you would have to be careful about setting the defaults before any app imports, which is easy to forget.The following a much safer and explicit pattern:
config.js
index.js
some-component.js
Thoughts on this?
The text was updated successfully, but these errors were encountered: