Context startup events
I'm evaluating Robotlegs ( I really like the look of it ) and I
see 2 ways of proceeding in the contexts startup method. One
example calls super.startup() which in turn dispatches
ContextEvent.STARTUP_COMPLETE. The other example does not call the
super method and instead dispatches ContextEvent.STARTUP.
Which one is correct? I'm assuming one of those events must be required for the rest of the robots to begin doing something.
Thanks!
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 levi.strope on 11 Jan, 2010 05:36 PM
It is my understanding that you don't need to dispatch either of these events.
I have noticed that If I try to listen for these events that they never get caught - I've found that if I want to do something on STARTUP_COMPLETE I had to dispatch this myself on the last line of Context.startup();
Support Staff 2 Posted by Joel Hooks on 11 Jan, 2010 05:39 PM
both do the same thing and neither are "correct" I personally dispatch it explicitly in my concrete startup just for clarity in my own apps.
3 Posted by shawn on 11 Jan, 2010 07:53 PM
Ok, it seems most examples use the explicit dispatch, so I guess I'll go that route. Thanks for the quick responses! I guess we are probably stuck with both since I'm sure many people went different routes.
4 Posted by jadd on 11 Jan, 2010 08:08 PM
hello. another stupid question. Why the explicit dispach works for me and the other super.startup does not.?
5 Posted by shawn on 11 Jan, 2010 08:20 PM
Are you explicitly dispatching the same event that super.startup uses?
Support Staff 6 Posted by Shaun Smith on 11 Jan, 2010 08:25 PM
super.startup() will fire a ContextEvent.STARTUP_COMPLETE event. When developing modules it is often useful to know (from the outside) when a context has been fully initialized.
By overriding startup() you, the app developer, are intercepting this flow and it is up to you to dispatch this event manually. You might not do this directly from the startup() method - perhaps some asynchronous call needs to be made first - you might dispatch it from a command, or you might not even dispatch it at all.
STARTUP and STARTUP_COMPLETE are simply provided for app development convenience, they don't play any part in Robotlegs itself.
For large applications/contexts, a suggested workflow is as follows:
For smaller apps this is unnecessary as all the initialization happens in the startup() method, and we can consider the application "started" by the end of that method.
Hope that helps!
7 Posted by shawn on 11 Jan, 2010 09:08 PM
Yes it does. Thanks!
Shaun Smith closed this discussion on 13 Feb, 2010 05:20 PM.