Starling + Robotlegs

smival's Avatar


12 Nov, 2014 10:05 AM

Hi there, I am trying to use this framework (based on Robotlegs) -
I am going to refactor some project from StarlingMVC and I can't understand how to Inject Model property to Mediator, for StarlingMVC I use following code:

public function set onFsModeStarted(value:Boolean):void

and it frows this error - Error: Injector is missing a rule to handle injection into property "onFsModeStarted" of object "[object MainViewMediator]". Target dependency: "Boolean", named "gameModel.fsModeStarted"

So how can I handle model changing for Mediator or any another class?

  1. Support Staff 1 Posted by Ondina D.F. on 12 Nov, 2014 02:05 PM

    Ondina D.F.'s Avatar

    Hi Valentin,

    There is an example application using the framework that you mentioned:

    It seems, that models are injected like this:



  2. 2 Posted by smival on 12 Nov, 2014 02:39 PM

    smival's Avatar

    yeah I saw this example and there is nothing to explain my question.
    My question is how to inject each specific property of some model into Mediator.
    Part of code for a Mediator:

    public function set onFsModeStarted(value:Boolean):void
    trace("prop has been changed")

    I have a lot of properties in Model and mediator need to be notified when each property of Model has been changed. One model property - one handler function in Mediator, not for all properties but most of them

  3. Support Staff 3 Posted by Ondina D.F. on 12 Nov, 2014 04:39 PM

    Ondina D.F.'s Avatar

    That's an unusual use of Models. That's the first time I hear of needing to inject each property of a Model into other classes while using robotlegs.
    I guess, you're after the binding mechanism that StarlingMVC offers. Swiftsuspenders' injection doesn't work like StarlingMVC.
    I don't know if joshtynjala/robotlegs-framework-starling provides features that facilitate such a usage. You might want to contact Josh for further explanations or assistance with issues specific for Starling or his framework.

    With the original robotlegs, we usually inject a model like so:

    [Inject] public var someModel:SomeModel;

    and access model's properties like so:


    Or, when we want a class to be notified when model's properties change, we dispatch an event from within the model's setter for a certain property (or other methods of your choice). Such a model is injected with a shared event dispatcher, in order to be able to dispatch events, in robotlegs 2 ( like the Actor class in Robotlegs v. 1 )
    The event can carry a payload, if need be.
    Or, if you're using as3-signals, the model can dispatch a signal when its properties change.

    Mediators can listen for events from Models and do whatever they need to do in the handlers for those events, where they can access the event's payload ( the model's property that changed, for example)

  4. smival closed this discussion on 20 Nov, 2014 01:46 PM.

  5. smival re-opened this discussion on 20 Nov, 2014 01:50 PM

  6. 4 Posted by smival on 20 Nov, 2014 01:50 PM

    smival's Avatar

    thanks for explanation

  7. smival closed this discussion on 20 Nov, 2014 01:50 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac