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
Right now it's possible to have two Meydas, but it's tricky. Meyda is actually a singleton, so the same top-level defaults are shared across the entire running program. Because we tell people to set these parameters to whatever they need, it's possible that one part of a program sets them, then another part of the program imports Meyda expecting defaults, but receiving whatever was previously set by whichever random other part of the program previously used Meyda. This is demonstrated in RunKit.
It's possible to do a second Meyda by running const secondMeyda = Object.assign({}, Meyda); - but I'm not actually sure that the functions end up bound to the correct this. Also, unless you have a really deep understanding of your build process, all your dependencies, and your own entire codebase, you can't be sure that the Meyda you import has the correct defaults - or will have them in the future after patches and updates. Demonstrated in RunKit.
You can wrap the above hack in a constructor, but of course it faces the same problems.
There's not much of a way around this without overhauling the whole API. So I think this might just be the realization that sparks an enormous amount of work.
The text was updated successfully, but these errors were encountered:
here's a link to a runkit I'll be referencing
Right now it's possible to have two Meydas, but it's tricky. Meyda is actually a singleton, so the same top-level defaults are shared across the entire running program. Because we tell people to set these parameters to whatever they need, it's possible that one part of a program sets them, then another part of the program imports Meyda expecting defaults, but receiving whatever was previously set by whichever random other part of the program previously used Meyda. This is demonstrated in RunKit.
It's possible to do a second Meyda by running
const secondMeyda = Object.assign({}, Meyda);
- but I'm not actually sure that the functions end up bound to the correctthis
. Also, unless you have a really deep understanding of your build process, all your dependencies, and your own entire codebase, you can't be sure that the Meyda you import has the correct defaults - or will have them in the future after patches and updates. Demonstrated in RunKit.You can wrap the above hack in a constructor, but of course it faces the same problems.
There's not much of a way around this without overhauling the whole API. So I think this might just be the realization that sparks an enormous amount of work.
The text was updated successfully, but these errors were encountered: