merkle-open / gondel

🚡 Gondel is a tiny library to bootstrap frontend components
https://gondel.js.org
MIT License
36 stars 10 forks source link

fix(gondel decorator): prevent duplicated events with multiple gondel… #49

Closed janwidmer closed 5 years ago

janwidmer commented 5 years ago

… core instances in different files

Purpose of this pull request?

What changes did you make?

use window to define a global state variable, if Core Events have been initialized.

Does this pull request introduce a breaking change?

No

Closes https://github.com/namics/gondel/issues/48

jantimon commented 5 years ago

gondel already provides global variables:

gondel-globals_-_StackBlitz

instead of introducing a new global variable areEventsHookedIntoCore without prefix we should rather reuse __gondelPluginEvents or even better extend gondelPluginEvents to provide this feature out of the box by allowing to register a plugin only once per namespace

janbiasi commented 5 years ago

And we should also type the __gondelPluginEvents global 😄 gonna propose some fixes in here.

jantimon commented 5 years ago

Hey @janbiasi I took a look together with @janwidmer to address the root of the problem and found a solution which looks promising (however it will introduce a small breaking change)

janwidmer commented 5 years ago

Will be done in new PR