Skip to content
This repository was archived by the owner on Jan 22, 2021. It is now read-only.

Conversation

@todoooo
Copy link
Contributor

@todoooo todoooo commented May 23, 2019

This change set adds a feature found in .NET, whereby the same type name can be registered multiple times with different tags/selectors, so that a keyed container is returned with the ability to lookup a particular type at runtime.
e.g.
$jsInject.register('WidgetFactory', [() => new WidgetFactoryA()], 'WidgetA');
$jsInject.register('WidgetFactory', [() => new WidgetFactoryB()], 'WidgetB');

var factory = $jsInject.get('WidgetFactory', 'WidgetB');
or
var provider = $jsInject.get('WidgetFactory');
var factory = provider['WidgetB'];

@JeremyLikness
Copy link
Owner

Hi, in the spirit of this being a tool for teaching DI I don't want to overly complicate the implementation. I like the changes and have two suggestions ... either (a) fork and release there, or (b) update the README to explain the changes and I will merge here. Thanks for your time and contributions!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants