Description
I have run into some cases where I want my components to be able to be passed methods at construction time.
I can't require
/import
the library inside the component, because it's a stateful module that the app should compose with the component.
I can't use events in these cases, because I need to capture the return value of the methods.
So far, I've gotten around this by passing in the functions on the data object, as with the svelte-state-renderer
here.
This works fine when calling them from the template, but it looks pretty clunky in the lifecycle functions and custom methods - I have to call something like this.get('dispatch')(action).then(...)
instead of this.dispatch(action).then(...)
.
This is a bit of an annoyance. It would be nice if I could pass in dispatch
or makePath
methods when constructing the component.
Is it worth it? I'm not sure, what do you think?