tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/4817-object-does-not-get-dependencies-injected-into-it-when-it-is-mapped-using-tovalueRobotlegs: Discussion 2013-10-11T08:52:32Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/283931362013-08-22T17:39:10Z2013-08-22T17:39:10ZObject does not get dependencies injected into it when it is mapped using toValue()<div><p>Yeh, that's a troublesome one, as objects aren't really
"managed" in RL/SwiftSuspenders, and we made a conscious decision
<em>not</em> to inject into values provided to toValue().</p>
<p>The easiest thing would probably be to create a config class and
add it as the final config. Inject IUITrackingService and the
injector into it, and call injectInto in the config method.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/283931362013-08-23T12:56:57Z2013-08-23T12:56:57ZObject does not get dependencies injected into it when it is mapped using toValue()<div><p>Thanks, it works fine to add the mapping and do the injection
after the context is initialized.</p>
<p>But perhaps you can suggest a better approach for what I'm
doing..</p>
<p>There's a parent context that contains a factory, each child
context needs it's own instance created by that factory, so that it
can be injected with different objects.</p>
<p>I know that the parent context will be available already, so I'm
injecting the factory into the child's config, then using it to
create an instance. Then I'm adding a mapping to the child, and -
now - I'm using injectInto to perform injections there.</p>
<p>Could you suggest a better approach using existing RB
extensions?</p></div>peter.hall