18alantom / strawberry

Zero-dependency, build-free framework for the artisanal web.
https://strawberry.quest
MIT License
681 stars 15 forks source link

Global Shared Data/State #32

Open kalisjoshua opened 1 year ago

kalisjoshua commented 1 year ago

Is there a way to "hide" the globally available strawberry object? I'd like to use this for a game and I am not figuring out how to hide access to the initialized reactive data object.

18alantom commented 1 year ago

You can kinda hide the reactive data object by calling sb.init inside a non global scope. But subsequent calls to sb.init returns the same object.

Will have to push an update that makes multiple calls to sb.init a no-op that returns undefined, the sb object would still be available though.


Possible solution https://github.com/18alantom/strawberry/pull/33 ∵ ESM modules don't share global state and imports aren't accessible from the console.