Home

Awesome

SwiftSuspenders

Attention: This README is just a stub to prevent you from reading the heavily outdated one for Swiftsuspenders 1.x.

That being said, here's a very quick outline of the new version's capabilities and API:

Features

API

Requests

Requests, aka injection points, can be defined using the metadata tag [Inject] atop the var, setter or method to inject into. For constructor injection, no metadata is required.

Named injections can be defined using the syntax [Inject(name="injection name")]. In this case, constructors have to have their metadata placed atop the class itself, not the constructor. This is a limitation of the Flex compiler.

Optional injection requests can be defined using the syntax [Inject(optional=true)]

Mappings

The API is expressed as a DSL to make very fine-grained configuration of each mapping easy and readable:

const injector : Injector = new Injector;

//create a basic mapping:
injector.map(Sprite); //will instantiate a new Sprite for each request for Sprite

//map to another class:
injector.map(Sprite).toType(BetterSprite); //will instantiate a new BetterSprite for each request for Sprite

//map as a singleton:
injector.map(EventDispatcher).asSingleton(); //will lazily create an instance and return it for each consecutive request

//map an interface to a singleton:
injector.map(IEventDispatcher).toSingleton(EventDispatcher);

Beta

So, that's it for now as far as documentation is concerned. The implementation, on the other hand, is very stable and shouldn't regress anything that used to work in 1.x, as long as the API changes are dealt with, of course.

More documentation will soon come here, in the github wiki and as asdocs.