SignalCommandMap: Creation point of a Signal Value Object when used in a View Class

thomas.thorstensson's Avatar

thomas.thorstensson

16 Aug, 2012 09:45 AM

Hello Dear Robotlegs users :

I've set up, for lab purposes, my own Signals Command project and It's working fine.
I follow the concept that the view dispatches an instance of a Value Object so in my View I have:

item=new ItemVO(); itemAdded=new Signal(ItemVO); itemAdded.dispatch(item);

...which is forward passed to my Mediator which pipes it to the framework using a signal in present tense.

However I realise that a view might not be the right location to create my Value Object above? Or is the above approach commendable?

Glad for any feedback, Have a sunny day now,
Thomas

  1. Support Staff 2 Posted by Ondina D.F. on 16 Aug, 2012 12:49 PM

    Ondina D.F.'s Avatar

    Hi Thomas,

    You can gather View’s data into a new VO and then transport it around in an application (as a payload of events or signals):

    var someVO: SomeVO = new SomeVO (someTextInput.text);
    or
    var someVO: SomeVO = new SomeVO ();
    someVO.someProperty= someTextInput.text;

    Another way is something like this:

    var someVO:SomeVO = someListDataProvider.getItemAt(index) as SomeVO;

    It’s hard to say what you need (a new VO or just strongly typed data) in your View without knowing more details.

    I’m sure you’ve already read articles on this forum about VOs and Models. It’s such a big topic.
    Have a look at some examples to see how people use VOs in different ways, depending on their preferences and/or requirements.

    http://tinyurl.com/cp8uw7n

    http://tinyurl.com/d26w2jv

    http://tinyurl.com/brby48b

    http://tinyurl.com/c9nzd6o

    Cheers,
    Ondina

  2. 3 Posted by thomas.thorstensson on 16 Aug, 2012 12:55 PM

    thomas.thorstensson's Avatar

    Hello Ondina

    Yes I used VO:s for years but usually I create them in my Model, not in my View. Sometime I inject them (but again not in my View).

    I read that when using SignalCommands it's a good practice to use value objects as the parameter when talking from view to mediator. I always used Signals before but as I have not used the SignalCommand approach before those signals mainly carried string data or other data rather than VO:s.

    However the Views have of course recieved VO:s via mediator from the framework.

    So what I',m now thinking about doing thus is:

    Create VO in my View. Use a past tense signal to notify my Mediator of the VO, and from there on use a present tense Signal to pass VO from Mediator to framework.

    However, perhaps that the first part, always using VO:s when communiciating FROM view to mediator (to enfore stronly typed objects) are not needed.

    But I see that Joel Hooks is doing so in his SignalCommand example.

    Thanks for such a speedy reply!

  3. 4 Posted by thomas.thorstensson on 16 Aug, 2012 08:16 PM

    thomas.thorstensson's Avatar

    I am happy with reply and this discussion can thus be closed! I have also created and uploaded a zip of my SignalCommandMap study: it's a pure AS3 Flashbuilder project, better late than never!

    http://www.thumbleaf.com/journal/?p=574

    Until next time, and thanks!

  4. Support Staff 5 Posted by Ondina D.F. on 17 Aug, 2012 07:30 AM

    Ondina D.F.'s Avatar

    Hehe Thomas, I’m happy that you are happy.

    I’ve added your example to the list:

    http://knowledge.robotlegs.org/discussions/resources/33-links-to-ro...

    (I like the images on your blog)

    Ondina

  5. Ondina D.F. closed this discussion on 17 Aug, 2012 07:30 AM.

  6. thomas.thorstensson re-opened this discussion on 17 Aug, 2012 08:56 AM

  7. 6 Posted by thomas.thorstensson on 17 Aug, 2012 08:56 AM

    thomas.thorstensson's Avatar

    This discussion can be reclosed just want to say thanks for the link!

    Thomas, over coffe

  8. Ondina D.F. closed this discussion on 17 Aug, 2012 09:41 AM.

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

Keyboard shortcuts

Generic

? 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