Provide/inject for EffectScope #563
rockwalrus
started this conversation in
General
Replies: 1 comment
-
I keep running into this. I found this issue just now only to learn that I had previously already upvoted it over a year ago! Struggling to come up with any workaround too. I don't think there's currently any way to associate a state with an effect scope and all its descendants. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What problem does this feature solve?
When writing composables that are used by both a component and its descendants, it would be good to inject the dependencies, but this is not possible because components cannot provide to their own composables.
EffectScope.provide
can also be used to inject dependencies into composables in contexts other than componentsetup
.What does the proposed API look like?
EffectScope.provide(key, value)
would provide a value to the scope and all nested scopes that do not override it. In the common case, users will call it on the result fromgetCurrentScope()
.While it could be desirable to have
inject
inject from the current scope, this probably would lead to backwards compatibility edge cases. Instead, they are injected viaEffectScope.inject(key)
.Beta Was this translation helpful? Give feedback.
All reactions