map().toValue() doesn't do injectInto
In most of cases I did something like:
injector.map(Foo).toValue(new Foo("property"));
I also did
var foo:Foo = new Foo("property");
injector.map(Foo).toValue(foo);
injector.injectInto(foo);
So it's 3 lines of code against one. I think, it should be great to have a syntax sugar like
injector.map(Foo).toValue(new Foo("property"), true);
Witch will also do injectInto, this well make config shorter and more readable. What do you think?
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by matej on 03 Feb, 2014 11:43 AM
well :)
you can always do
injector.map(Foo).toValue(injector.instantiateUnmapped(Foo));
or simple
injector.map(Foo).asSignleton();
2 Posted by lahmataja.pa4va... on 03 Feb, 2014 12:27 PM
whell :)
This is of course possible, but the code of config should be as clean as possible, as I think. Maybe even better solution should be:
injector.map(Foo).asSignleton(true);
where true means, that service should be auto initialized even if not injected (for example for events observing).
3 Posted by matej on 03 Feb, 2014 02:20 PM
I like that approach :)
4 Posted by ishaban.flash on 04 Feb, 2014 04:10 PM
I vote for those features, it will be handy imho.
5 Posted by lahmataja.pa4va... on 04 Feb, 2014 05:33 PM
The question is, how to implement it in the correct way. Actually all singeltons are created on demand. The question is, how force instance creation as soon, as it's configured.
6 Posted by ishaban.flash on 26 May, 2014 02:20 PM
Please close topic, because solution implemented in swiftsuspenders 2.2.1.
Support Staff 7 Posted by Shaun Smith on 26 May, 2014 02:26 PM
Cool
Shaun Smith closed this discussion on 26 May, 2014 02:26 PM.