Skip to content

Instantly share code, notes, and snippets.

@alecmce
Created August 25, 2012 00:33
Show Gist options
  • Save alecmce/3457938 to your computer and use it in GitHub Desktop.
Save alecmce/3457938 to your computer and use it in GitHub Desktop.
injecting data deeper?
// 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