Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

changed doc title for proper ordering

  • Loading branch information...
commit 481cd58de71417faa9c2275688b12281d0747f56 1 parent e6af544
@joelhooks joelhooks authored
Showing with 26 additions and 0 deletions.
  1. +26 −0 best-practices/3_0_injection.textile
View
26 best-practices/3_0_injection.textile
@@ -0,0 +1,26 @@
+h2(#usingtheinjectors). Using Injectors
+
+Robotlegs provides an adapter mechanism for providing a dependency injection mechanism to the framework. By default, the framework is equipped with the "SwiftSuspenders":http://github.com/tschneidereit/SwiftSuspenders injection/reflection library to serve this purpose. Additional adapters are available for SmartyPants-IoC and Spring Actionscript. There can potentially be specific reasons to use another dependency injection adapter, but if you don't have a specific reason for doing so, it is recommended that you use the default "SwiftSuspenders":http://github.com/tschneidereit/SwiftSuspenders as it is performance tuned specifically for Robotlegs.
+
+h3(#injectionsyntax). Injection Syntax for the SwiftSuspenders Adapter
+
+SwiftSuspenders supports three types of dependency injection.
+
+* Property (field) Injection
+* Parameter (method/setter) Injection
+* Constructor Injection
+
+For the purposes of this document, we are going to examine Property injection, and how this is used within Robotlegs. There are two options for injecting properties into your class. You can use unnamed, or named injection:
+
+<pre>[Inject]
+public var myDependency:Depedency; //unnamed injection</pre>
+
+<pre>[Inject(name="myNamedDependency")]
+public var myNamedDependency:NamedDepedency; //named injection</pre>
+
+Injection mappings are supplied to Robotlegs in three places. The MediatorMap, the CommandMap, and through the Injector directly. Both the MediatorMap and the CommandMap are making use of the Injector as well, but they are doing additional work required by these tiers. As the names imply, MediatorMap is used for mapping Mediators, CommandMap is used for mapping Commands, and anything else that needs to be injected (including but not limited to Models) is mapped directly with the Injector.
+
+
+
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.