tschneidereit / SwiftSuspenders

NOTE: Find the offical repo at http://github.com/robotlegs/swiftsuspenders
https://github.com/robotlegs/swiftsuspenders
MIT License
280 stars 89 forks source link

Feature Request -- "Mapping"-specific injections #85

Open LandonLunsford opened 11 years ago

LandonLunsford commented 11 years ago

After using this framework extensively, one thing I found myself repeatedly wanting was a way for it to help me cleanly separate configuration from behavior.

Currently, to satisfy this need, I rely on name-qualified injection points which unfortunately are highly coupled with the class instead of the mapped object's key.

class Poo{ [Inject(name="poo.stink")] public var stink:Stink; }

What I would like to see is something like the following:

injector.map('application.somepoint') .toType(flash.geom.Point) .withArgument(50) .withProperty('y',100); const point:Point = injector.getInstance('application.somepoint') as Point; assertEquals(50, point.x); // true assertEquals(100, point.y); // true

Much like an object mocking framework, this feature would greatly increase the re-usability of classes -- eliminating the need to rely on inheritance models resulting in class explosion.

Thoughts?