在app配置文件中,我有一个Signal / Command映射
signalCommandMap.map(DisconnectUserSignal).toCommand(DisconnectUserCommand);
然后, 我有两个连接类:
public class BaseConnection implements IBaseConnection
{
// When I am trying to inject the signal here:
[Inject] public var disconnectUserSignal:DisconnectUserSignal; // it is always null
_netConnection = new NetConnection();
...
}
和
public class BBConnection extends DefaultConnectionCallback implements IBBConnection
{
// When I am trying to inject the signal here:
[Inject] public var disconnectUserSignal:DisconnectUserSignal; // it works perfectly fine
_baseConnection = new BaseConnection(this);
}
是否有任何可能的原因? 谢谢
答案 0 :(得分:0)
在浏览了robotlegs框架文档之后 - 我找到了答案:
我将_baseConnection更改为一个接口,并将所有内容从BaseConnection的构造函数移动到init方法中,现在我将它注入到我的BBConnection中。
BBConnection现在看起来如何:
[Inject]
public var baseConnection:IBaseConnection;
public function BBConnection()
{
}
[PostConstruct]
public function init():void
{
baseConnection.init(this);
}
现在我可以在基础连接中成功注入Disconnect信号。