jsInject icon indicating copy to clipboard operation
jsInject copied to clipboard

Feature register multiple with selector tags

Open todoooo opened this issue 6 years ago • 1 comments

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'];

todoooo avatar May 23 '19 02:05 todoooo

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!

JeremyLikness avatar Jul 08 '19 18:07 JeremyLikness