ltackmann / dice

Lightweight dependency injection framework for Dart
Other
34 stars 7 forks source link

Name parameter and registration/unregistration at runtime at Injector level #14

Closed cwkr closed 9 years ago

cwkr commented 9 years ago

Hi,

I hacked a bit on your code and made changes that may be usefull for outhers too, but it breaks compatibility in some cases.

23dcabd just resolves issue #11

The other changesets move the registration map from modules to the Injector. It makes unregistration at runtime possible and allows registration without subclassing a module. Example:

var injector = new Injector();
      injector
        ..register(MyClass).toType(MySpecialClass)
        ..register(YourClass)
        ..register(MyClass, 'test').toType(MySpecialClass);

var myClass = injector.getInstance(MyClass);
var yourClass = injector.getInstance(YourClass);

injector.unregister(MyClass);
injector.unregister(YourClass);

var myNamedClass = injector.getInstance(MyClass, 'test');
ltackmann commented 9 years ago

Thanks for the pull request I like the enhancements. Keep them coming ;)

Could you bump the version to 1.6 in pubspec and update the README (I will get around to it in a few days if you don't have the time).