-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IInjector #136
Comments
@darscan Have you thought about this? My vote is 👍 for |
I have a habit of stating the obvious. |
It's not a problem, except for the pain in my knee each time I kick in an open door. |
I'm just worried I'll need a wheel chair when I grow old. |
Older, I mean, older. |
Ha! Yes, it would be nice, but I seem to remember trying to create an IInjector in the framework api package and failing. Feel free to give it a "bash" |
As a devout pastafarian I have bolognetic amounts of faith. His noodly On Sat, Jun 1, 2013 at 4:42 PM, Shaun Smith [email protected]:
|
I feel a bit weird today, maybe I should eat something. On Sat, Jun 1, 2013 at 5:49 PM, Camille Reynders <[email protected]
|
Good lord man! Have a salad.. The pasta will surely exacerbate your condition. On 1 Jun 2013, at 16:49, creynders [email protected] wrote:
|
But obviously it's a bit hum-hum, since I had to rename Another (probably the better) option would be to fork SS and do it there. I think that might be the best approach anyhow, to rely on our own fork. |
Holy crap, you updated all the call sites! I think we should fork Swiftsuspenders.. Till hinted at this a while back. Well, he mentioned incorporating Swiftsuspenders into the Robotlegs organisation. Now's as good a time as any. |
It's just going to be awkward when people try to use the "official" swiftsuspenders SWC with RL.. |
Well of course.
Yeps.
There's not a lot of reason to do that, is there? Obviously we'll have to make it clear we're using a fork. |
Hmm... I'm having serious second thoughts about this.. Perhaps we should just rename |
Yeah, but it allows us to introduce changes when necessary. That's my main Were there call sites you wanted to leave as is, if possible? On Sun, Jun 2, 2013 at 8:57 PM, Shaun Smith [email protected]:
|
From a maintenance and feature development perspective I'd still like to bring Swiftsuspenders into the Robotlegs organisation. But, it's still a stand-alone library, and I wouldn't want to apply changes purely for some aesthetic benefit to the Robotlegs framework. Looking at what you've done here, I quite like the fact that the |
So, with this change, the context maps the injector instance as |
I'd go for loud!
Speaking of which, shall I add some syntactic sucrose to map multiple types to one? |
Ah yes, I had forgotten about that.. |
So, I started sketching out the syntactic sugar: //--( setup )--//
injector.map(IReadOnly).toSingleton(SomeModel);
//--( API sketches)--//
//1. ugly shizzle - possible
injector.reuseRuleOf(IReadOnly)
.forType(IWriteOnly);
//2. so-so - problematic
injector.map(IWriteOnly)
.toRuleOf(IReadOnly);
//3. my preference - problematic
injector.map(IReadOnly)
.and(IWriteOnly)
.toSingleton(SomeModel);
//4. idiotic, but most "honest" - possible
injector.useSingletonOf(IReadOnly)
.with(IWriteOnly);
//5. maybe most pragmatic solution - possible
const provider:DependencyProvider = injector.getProvider(IReadOnly);
injector.map(IWriteOnly).toProvider(provider); If I'm not mistaken the only real use case for this is when you want to map multiple types to the same singleton, right? Either for a I'd prefer 3/ because it's the most readable, but obviously it only solves a part of the problem, since you'd still need a separate sugary method to reuse a provider outside the mapping chain. With 'problematic' I mean we'd need to modify SS. There's simply no way around it. I'm leaning towards 5/ but maybe that's just because I'm not satisfied with any of the other method names. But 5/ is a bit opaque IMO. |
So, I reckon that this needs to be solved at the library level (and not in our adapter). I'd prefer to keep the adapter interface 1-1 with the Swiftsuspenders API (where possible). Perhaps we should put this on hold until we've brought the repo into our org? |
I'd rather opt for the getProvider solution, and go 1-to-1 when possible, On Tuesday, June 4, 2013, Shaun Smith wrote:
Sent from Gmail Mobile |
I see that |
Pushed it to reuse_rule |
created dedicated issue for IInjector#getProviderFor |
ha! been creating some SSInjector dependent utils and now wamt to use in RL2. face palm |
actually, all I have to do is to map Injector to Injector... mmm |
So, what do you think? If we're adding it, it should be now, I think.
See tschneidereit/SwiftSuspenders#88
And also http://knowledge.robotlegs.org/discussions/robotlegs-2/2124-mapping-multiple-interfaces-to-same-singleton-instance
The text was updated successfully, but these errors were encountered: