Move registerDomBinding
to the createApp
interface
#29
Replies: 1 comment
-
This makes sense as we would be binding the I think the type being global is fine, as long as we expect that most Muban app's will be single-instance. For environments such as
I think that exposing the rest of the app to each component is quite dangerous, as any of the fields are susceptible to change. Moreover, it would be possible to store the instance or any of its fields in ways that we don't intend to, which might cause memory leaks. |
Beta Was this translation helpful? Give feedback.
-
Original task
Currently the
registerDomBinding
function is standalone, acting as a global.With the "recent" introduction of the
createApp
function, acting as the starting point of any app, it might make more sense to move theregisterDomBinding
to that location, scoped to the app.Even though the internal implementation might still use the bindingsList global (mostly for typing and use in applyBindings), that is all handled internally.
Moving this function will make the external API more future proof and stable.
The problem with this change, is that you might not always have access to the app instance. Example here is inside storybook, where muban-storybook is responsible for creating the app instance. There is currently no way to access this app instance from any component.
Questions
1. Should we move these kinds of functions to the app instance?
Pro; it feels more at home
Con; the types you have to update are global anyway, so why not keep the function global?
Other examples are
component
andprovide/inject
.For
provide/inject
this can be added to any component in the change.For
component
there is a workaround for Stories specifically, but this feels like a workaround.2. Should we allow access to the app instance from all components
If we move these functions to the app instance, should we allow access to the app instance from all components
Or maybe dedicated hooks to interact with it (like provide/inject)?
Beta Was this translation helpful? Give feedback.
All reactions