Open captainjono opened 7 years ago
👍 thanks for this suggestion. Sorry for the late reply I was on holidays... I will try to do something about this and share my plans here soon...
I'm using this:
inversifyContainer.bind = <any>_.wrap(inversifyContainer.bind, (originalBind, ...rest: any[]) => {
const binding = originalBind.apply(inversifyContainer, rest);
binding._binding.onActivation = (context, instance) => {
wireInstanceConfig(instance);
return instance;
};
return binding;
});
Terribly dirty, I know, but that's the only way for now.
I need this feature, too.
I will create a pull request for this tomorrow.
Lets say i have a series of modules defined for an app. Each module adds certain features to the app. I know that modules will provide services that implement certain interfaces.
At runtime, i want to know when any of these services are first resolved from the container, either directly, or indirectly via a child dependency resolution.
Currently with middleware, i can only see a way to get access to an instance of the directly requested service. The only way i can get access to the instance of the child service is to use the OnActivation method thats created during the binding.
This is a cross cutting concern, i cant/or want to do this at registration time. It would be great if this could be supported. Currently im using a forked version of the repo to meet this requirement.