Created
August 25, 2012 00:33
-
-
Save alecmce/3457938 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
// create a class that expects a MyData | |
public class SomeObject | |
{ | |
[Inject] | |
public var data:MyData; | |
} | |
// configure a signal to trigger a command that contains a reference to that class | |
injector.map(SomeObject); | |
signalCommandMap.map(MyDataSignal).toCommand(MyDataCommand); | |
// create a MyData and pass it into the signal, which triggers the command | |
var data:MyData = new MyData(); | |
data.message = "hello"; | |
myDataSignal.dispatch(data); | |
// so now the command is instantiated, which instantiates a new SomeObject, | |
// but the data from the signal doesn't make it through to the SomeObject, which is a bummer. | |
public class MyDataCommand | |
{ | |
[Inject] | |
public var object:SomeObject; | |
public function execute():void | |
{ | |
trace(object.data.message); // throws error because data is not injected into object | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment