-
-
Save vrobel/3458051 to your computer and use it in GitHub Desktop.
injecting data deeper?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this one works fine | |
package | |
{ | |
import flash.display.Sprite; | |
import robotlegs.bender.bundles.mvcs.MVCSBundle; | |
import robotlegs.bender.extensions.signalCommandMap.SignalCommandMapExtension; | |
import robotlegs.bender.framework.api.IContext; | |
import robotlegs.bender.framework.impl.Context; | |
public class Test extends Sprite | |
{ | |
private var context : IContext; | |
public function Test() { | |
context = new Context() | |
.extend( MVCSBundle, SignalCommandMapExtension ) | |
.configure( this, TestConfig ); | |
var myData : MyData = new MyData(); | |
myData.message = 'hello'; | |
var myDataSignal : MyDataSignal = context.injector.getInstance( MyDataSignal ); | |
myDataSignal.dispatch( myData ); | |
} | |
} | |
} | |
import org.osflash.signals.Signal; | |
import org.swiftsuspenders.Injector; | |
import robotlegs.bender.extensions.signalCommandMap.api.ISignalCommandMap; | |
import robotlegs.bender.framework.api.IConfig; | |
class MyDataSignal extends Signal | |
{ | |
public function MyDataSignal() { | |
super( MyData ); | |
} | |
} | |
class MyDataCommand | |
{ | |
[Inject] | |
public var someObject : SomeObject; | |
public function execute() : void { | |
trace( someObject.data.message ); | |
} | |
} | |
class SomeObject | |
{ | |
[Inject] | |
public var data : MyData | |
} | |
class MyData | |
{ | |
public var message : String; | |
} | |
class TestConfig implements IConfig | |
{ | |
[Inject] | |
public var injector : Injector; | |
[Inject] | |
public var signalCommandMap : ISignalCommandMap; | |
public function configure() : void { | |
injector.map( SomeObject ); | |
signalCommandMap.map( MyDataSignal ).toCommand( MyDataCommand ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment