Skip to content

Feature request: do not add DI user to context if not needed (add Deps.resolve method) #9

Description

@PFight

I want to use DI with React. For example, Im create a component, that should use some services. I will send a context to component via props or somehow.

So I should in constructor or in componentWillMount add the component to context, and call resolve in context? And library will resolve all objects in context? And then, when component will be disposed, I should remove it from context? WTF?

I suggest next API:

  1. Context should stores only injectable dependencies
  2. When we need resolve depenencies for some DI user, we call Deps.resolve(diUser, context)

With this API I will be abble to call in constructor of my component Deps.resolve(this, props.context), and library will resolve only dependecies of current component (do not touching entry application), and I will not have a pain of removing my component from context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions