Skip to content

Provide/inject for EffectScope #562

@rockwalrus

Description

@rockwalrus

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 component setup.

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 from getCurrentScope().

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 via EffectScope.inject(key).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions