Robotlegs 2 use cases

Quentin's Avatar

Quentin

27 Apr, 2012 12:46 PM

Hey there,
still playing with my test project to make sure I'm able to do everything I used to do with version 1.

Two things I can't really reproduce, yet:

Mediating the root Application

I used to have a simple

mediatorMap.mapView(MyAppView, MyAppViewMediator);

line in my Context. So I guessed I had to have a

mediatorMap.mapView(RL2FirstApp).toMediator(RL2FirstAppMediator);

in my AppConfig class, but it looks like it's not working. Tips?

Listening to a STARTUP_COMPLETE event to start doing things

I used to add event listeners like so:

commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE, StartDoingThings, ContextEvent, true);

(also in the Context class) but I can't find a way to listen to a similar event in RL2. Did I miss something?

That's it for now, but I may find other "migration" problems that I'd share here.
This discussion could also become a base for a RL to RL2 learn guide!

  1. 1 Posted by Michal Wroblews... on 27 Apr, 2012 03:12 PM

    Michal Wroblewski's Avatar

    Hi Quentin,

    1. Now you can call mediatorMap.handleView(contextView, RL2FirstApp); after it's mapped mediatorMap.mapView(RL2FirstApp).toMediator(RL2FirstAppMediator); It'll do the same as createMediator(contextView) in RL1.

    2. Currently it's using ManagedObject (which extends StateMachine) for Context lifecycle and you can achieve it by adding POST_INITIALIZE state handler context.addStateHandler(ManagedObject.POST_INITIALIZE, contextInitialized) and remember to have context:IContext injected to the config class. But as for the latest commits by @Stray there will be Lifecycle class which will be used instead of ManagedObject (I suppose) and a here you can find very well documented info about it

  2. Support Staff 2 Posted by Shaun Smith on 27 Apr, 2012 03:21 PM

    Shaun Smith's Avatar

    Hey Quentin,

    I'm not sure why the main view isn't being automatically mediated - but there's still work to be done in that area, so hopefully we'll sort that out soon.

    Regard point 2: I'd avoid dealing directly with ManagedObject/Lifecycle unless you are writing extensions. For normal app startup you can just include a simple config class as the last configuration in your setup and dispatch an event from that. There will be a better mechanism for this before the beta.

  3. 3 Posted by Quentin on 27 Apr, 2012 03:28 PM

    Quentin's Avatar

    Again, you (both) rock!
    Great answers, work perfectly.

    I know (I'm sure!) things will evolve for the best, just wanted to start playing with current version on GitHub.

  4. Support Staff 4 Posted by Shaun Smith on 27 Apr, 2012 03:34 PM

    Shaun Smith's Avatar

    Coolness, all feedback is useful :)

  5. 5 Posted by Paul Robertson on 27 Apr, 2012 09:05 PM

    Paul Robertson's Avatar

    I haven't specifically tried mediating the contextView, so I don't know the
    answer to your first item.

    My wild random guess is that maybe it's like in RL1 where in most cases you
    had to not only map your contextView, but also call createMediator() on it
    (since it already exists and is on the display list at the time
    Context.startup() was running. But I'm probably wrong.

    For the second one, you can just map your own custom startup event to your
    startup command(s), then dispatch that event at the end of your
    configuration sequence, e.g.:

    // in MyConfig startup() or configure() or whatever you call it
    // Requires injections for:
    // - commandMap:IEventCommandMap
    // - eventDispatcher:IEventDispatcher

    commandMap.map(StartupEvent.STARTUP, StartupEvent,
    true).toCommand(StartDoingThings);

    // ...

    eventDispatcher.dispatchEvent(new StartupEvent(StartupEvent.STARTUP));

    Paul

  6. 6 Posted by Quentin on 29 Apr, 2012 11:41 AM

    Quentin's Avatar

    Thanks for your suggestion Paul.

    I thought about doing so, and it makes perfect sense. Only thing is, I was wondering if such an event already existed, so I wouldn't have to write my own (like I used to do with RL1)!

    Seems like there isn't one, but that's perfectly fine!

  7. Ondina D.F. closed this discussion on 16 Jul, 2012 08:27 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