Search code examples
actionscript-3dependency-injectionrobotlegsswiftsuspenders

swiftsuspenders constructor parameters?


Once I read in some google document about coding guidelines that every new instance of a class should go from a factory class, and I use SwiftSuspenders for it.

Now my question is, is it possible to create a new instance of an object that requires constructor parameters using SS's dependency injection?


Solution

  • Yes, Swiftsuspenders fully supports constructor injection.

    You can either inject into a field (or a method or another constructor) requiring an instance of your class, or you can use injector.getInstance to directly query the injector for an instance that's created using the injector's mappings.