Robotlegs 2 use cases
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!
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
1 Posted by Michal Wroblews... on 27 Apr, 2012 03:12 PM
Hi Quentin,
Now you can call
mediatorMap.handleView(contextView, RL2FirstApp);
after it's mappedmediatorMap.mapView(RL2FirstApp).toMediator(RL2FirstAppMediator);
It'll do the same ascreateMediator(contextView)
in RL1.Currently it's using ManagedObject (which extends StateMachine) for Context lifecycle and you can achieve it by adding
POST_INITIALIZE
state handlercontext.addStateHandler(ManagedObject.POST_INITIALIZE, contextInitialized)
and remember to havecontext: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 itSupport Staff 2 Posted by Shaun Smith on 27 Apr, 2012 03:21 PM
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 Posted by Quentin on 27 Apr, 2012 03:28 PM
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.
Support Staff 4 Posted by Shaun Smith on 27 Apr, 2012 03:34 PM
Coolness, all feedback is useful :)
5 Posted by Paul Robertson on 27 Apr, 2012 09:05 PM
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 Posted by Quentin on 29 Apr, 2012 11:41 AM
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!
Ondina D.F. closed this discussion on 16 Jul, 2012 08:27 AM.