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