Inversion of Control (IoC) in AS3


I started reading about this subject a few weeks ago but yesterday i finally got it in my head.

My main problem trying to understand this metadata driven IOC for AS3 was the fact that until now, i had a bad time trying to understand how the hell did they make use of the [Inject] metatags and others like [PostConstruct]. So i burn my head for hours yesterday and i finally got it, i will post it here to help someone in my same situation:

This research was done using the SwiftSuspenders source code.

Ok, basically when you type any metatag (yes, you can make up your own) you can extract this information for later use in the XML that thedescribeType() method returns. Example: (i’m using Flex 4 open-source SDK to compile)

Then this IoC libraries use this data and the rules that you apply to them to make the IoC.

Ok, now that you know how they use the metatags you can read their documentation and understand a little more what’s going on.

Peace!

Advertisements