Great Work Remo,
What are the advantages you think of this library and for example just using a dictionary or a Map of singleton objects that you can pass on to constructors? Something like a Registry Pattern.
Its just I find the decorators in classes to be associated with mixins and I don't find that very appealing
Founder & CEO @ Wolk Software | EP @ JSConfIE | Former TypeScript Microsoft MVP, writer, speaker technology-lover and OSS enthusiast. Author of InversifyJS.
Thanks! Good question, InversifyJS allows you to have more control over the life-cycle of dependencies and how the dependency graph is composed than a dictionary of singletons. InversifyJS gives you more power thanks to 3 main features:
Scopes
At the moment the core library allows:
Transient scope (one instance each time you call container.get())
Singleton scope (same instance for every call to container.get())
I'm working on custom scopes which will allow singletons within a context as opposed to application-level singletons. This will enable things like "Request scope" which can be used to declare singletons at HTTP-request-level.
Contextual constraints
You can inject dependencies based on execution time constraints. InversifyJs supports many types of constraints:
InversifyJS allows you to implement interception thanks to the onActivation handlers and the @postConstruct decorator. You can learn more about IoC and interception here.
Great. I suppose this fine level of control will suit more to backend applications or really complex web apps with lots of services when you need something more customizable.
Founder & CEO @ Wolk Software | EP @ JSConfIE | Former TypeScript Microsoft MVP, writer, speaker technology-lover and OSS enthusiast. Author of InversifyJS.
Great Work Remo,
What are the advantages you think of this library and for example just using a dictionary or a Map of singleton objects that you can pass on to constructors? Something like a Registry Pattern.
Its just I find the decorators in classes to be associated with mixins and I don't find that very appealing
remonsinnema.com/2009/03/01/the-re...
Thanks! Good question, InversifyJS allows you to have more control over the life-cycle of dependencies and how the dependency graph is composed than a dictionary of singletons. InversifyJS gives you more power thanks to 3 main features:
Scopes
At the moment the core library allows:
I'm working on custom scopes which will allow singletons within a context as opposed to application-level singletons. This will enable things like "Request scope" which can be used to declare singletons at HTTP-request-level.
Contextual constraints
You can inject dependencies based on execution time constraints. InversifyJs supports many types of constraints:
You can do something like:
Interception
InversifyJS allows you to implement interception thanks to the
onActivation
handlers and the@postConstruct
decorator. You can learn more about IoC and interception here.Great. I suppose this fine level of control will suit more to backend applications or really complex web apps with lots of services when you need something more customizable.
Yes, InversifyJS becomes more valuable as your application grows.