Signal is never being injected - robotlegs2.0

109 views Asked by At

In app config file I have a Signal/Command mapping

signalCommandMap.map(DisconnectUserSignal).toCommand(DisconnectUserCommand);

Then, I have two connection classes:

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();
   ... 
}

and

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);
}

Is there any suggestion of what might be the reason? Thank you

1

There are 1 answers

0
inside On BEST ANSWER

After going through the robotlegs framework documentation - I found the answer:

I changed the _baseConnection to be an interface, and moved everything from BaseConnection's constructor into init method and now I am injecting it inside my BBConnection.

Here how BBConnection looks now:

[Inject]
public var baseConnection:IBaseConnection;

public function BBConnection() 
{
}

[PostConstruct]
public function init():void
{
   baseConnection.init(this);
}

Now I can successfully inject Disconnect signal inside base connection.

Source: https://github.com/robotlegs/robotlegs-framework/wiki/common-problems#injected-properties-are-null-in-constructor