Service dispatching events...

thomas.thorstensson's Avatar

thomas.thorstensson

09 Mar, 2012 05:33 PM

Hello Dear Robotlegs users,

I have a pretty dumb question but here goes as I Been doing both a) and b) without more than an "arbitrary" feel in my head :

Does it make sense to

a) When the service class has loaded the XML, dispatch its own event notifying a ViewMediator that the XML has loaded or
b) When the service class has loaded the XML, dispatch an event that the model listens to and model dispatches its own event notifying a ViewMediator that the XML has loaded

or
c) Get out of the kitchen and go eat cookies neither a) or b) makes sense Instead i propse c) Bla bla bla bla

Replies welcome

Thanks in Advance

Thomas

  1. Support Staff 1 Posted by Ondina D.F. on 10 Mar, 2012 11:23 AM

    Ondina D.F.'s Avatar

    Hi Thomas:)

    When the service class has loaded the XML, dispatch its own event notifying a ViewMediator that the XML has loaded or

    You can do that, if you don’t need a Model to work with the loaded data.

    When the service class has loaded the XML, dispatch an event that the model listens to and model dispatches its own event notifying a ViewMediator that the XML has loaded

    You can do that, too, but it’s not a recommended practice :) Models shouldn’t listen to events.
    You could:

    • let the Service set the data on the Model

    • or, let the Service dispatch an event, that would trigger a Command, that would call a method on the Model

    and let the Model dispatch an event with the updated data as a payload.

    or c) Get out of the kitchen and go eat cookies neither a) or b) makes sense Instead i propse c) Bla bla bla bla

    Diabetologists say, that eating cookies is not recommended while having issues with your code ;)
    Ondina

  2. 2 Posted by thomas.thorsten... on 10 Mar, 2012 11:30 AM

    thomas.thorstensson's Avatar

    Thanks for the reply. I really like the last approach with Command. Why did I not think of that! It's neat, and feels more proper than setting the data on the Model.

    Also, thanks for the insights about reduction of cookie eating during code issues. I shall try lemon tea, with a tad of sugar,

    Thomas

  3. Support Staff 3 Posted by Ondina D.F. on 10 Mar, 2012 12:47 PM

    Ondina D.F.'s Avatar

    You’re welcome.
    Yeah, lemon tea, with a tad of sugar and ONE cookie should be fine:)

  4. Ondina D.F. closed this discussion on 10 Mar, 2012 12:47 PM.

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