Provide/inject for EffectScope #563
rockwalrus
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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