Robotlegs Rss Reader

last 2 Weeks I was playing with Robotlegs (yeah, again), before using it for the specific project I decide to make couple of examples to fallow the “right” path and of course get input from community experts. The example we are building here gonna be simple rss reader: input field, load button, result.
Required library: robotlegs-framework-v1.4.0.swc
Flash Builder 4 used to run and compile project.

I could probably avoid using model and command in this example but as mentioned try to use all “parts” of the framework in right order.
The main source for me was best practices documentation and 3 tutorials from J. Hooks :

Flow of the Rss reader:

  • ReaderViewMediator listens for load button click, and fires FeedLoadEvent event
  • FeedLoadEvent runs FeedLoadCommand
  • FeedLoadCommand starts FeedLoadService
  • FeedLoadService loads the XML
  • FeedServiceResultParser converts loaded data to array of ReaderItemVO value objects
  • FeedLoadService notifies to FeedLoadCommand with parsed data
  • FeedLoadCommand updates ReaderModel
  • ReaderModel notifies the ReaderViewMediator that data is updated
  • ReaderViewMediator updates ReaderView

Inputs, suggestions, corrections are welcome!
Finished Rss Reader(view source is available):

Get Adobe Flash player

2 thoughts on “Robotlegs Rss Reader

  1. Stray

    Nice work!

    You have followed ‘the robotlegs way’ really nicely – with all the benefits – well separated, simple classes that know what they’re doing.

    I had only two suggestions – one major and one minor.

    The major one is that you should be using the eventMap rather than listening directly to the view button in the ReaderViewMediator. An easy fix :)

    eventMap.mapListener(view.loadBtn, MouseEvent.CLICK, onLoadClick, MouseEvent);

    The minor one is that in onRegister of your ReaderViewMediator, you’re forcing the button to dispatch an event. This is obfuscating what you’re actually trying to do – which is load the default stream.

    I would break the actual content of the onLoadClick handler into a function. loadRequestedStream() – then in your onRegister you can just run loadRequestedStream() and it’ll be more obvious what your intent is (and you can run it in the onLoadClick handler as well).

    Thanks for sharing!


  2. Armen Abrahamyan Post author

    @Stray thanks for the comment.

    eventMap.mapListener(view.loadBtn, MouseEvent.CLICK, onLoadClick, MouseEvent);

    got it.

    as for the dispatching event, I was actually lazy there, kinda fast fake startup.
    making more sense to do it the way u mentioned.

    I have one question that bothers me here, lets say I don’t wanna use model here, the logical answer for me would be inside command instead of :
    model.feedData = event.result;
    just use:
    dispatch(new DataUpdateEvent(DataUpdateEvent.DATA_UPDATED,event.result));

    but since I’m already inside event handler, can I just redispatch the same event(FeedResultEvent)?(probably with different type).

    Thanks again for the comment.

Leave a Reply

Your email address will not be published. Required fields are marked *