massive-oss / minject

A Haxe port of the ActionScript 3 SwiftSuspenders IOC library with efficient macro enhanced type reflection. Supports AVM1, AVM2, JavaScript, Neko and C++.
open.massiveinteractive.com
Other
54 stars 22 forks source link

Recursive singleton injection #12

Closed dpeek closed 11 years ago

dpeek commented 11 years ago

Injecting components into each other causes the app to crash.

class Test1
{
        @inject public var test:Test2;
        public function new() {}
}

class Test2
{
        @inject public var test:Test1;
        public function new() {}
}

class Test
{
        static function main()
        {
                var injector = new minject.Injector();
                injector.mapSingleton(Test1);
                injector.mapSingleton(Test2);
                injector.getInstance(Test1);
        }
}
IanCallaghan commented 11 years ago

Wow that was fast awesome stuff :)