Futurescale, Inc.
PureMVC Home
The PureMVC Framework
Code at the Speed of Thought
Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
New discussions should be taken up in issues on the appropriate projects at
https://github.com/PureMVC
PureMVC Architects Lounge
Announcements and General Discussion
General Discussion
Should a Command add an event listener?
Pages: [
1
]
« previous
next »
Author
Topic: Should a Command add an event listener? (Read 4062 times)
jaxim
Full Member
Posts: 22
Should a Command add an event listener?
«
on:
April 09, 2010, 09:33:50 »
I'm new to PureMVC, so i want to double check if what I am planning on doing is considered best practice or if there is a better way.
I have a Startup Command that registers a proxy. The proxy takes awhile to get its info, which is needed to start the application. In the meantime, nothing can be done until this info is returned, so there are no other proxies, mediators, etc. Currently, I have the startup Command add an event listener to the proxy and wait until the proxy indicates that the info has been returned. When the info is returned, then the startup command registers the rest of the start up proxies and mediators that use this initial data.
The startup command is only called once.
Is this an okay practice? Is there a better way to go about this?
Logged
puremvc
Global Moderator
Hero Member
Posts: 2871
Re: Should a Command add an event listener?
«
Reply #1 on:
April 11, 2010, 12:45:26 »
Not good, no.
You don't really want to kick Proxies into action when they're registered, otherwise you end up with these sort of issues.
You should register the Proxies, let them create their services or delegates, etc, but then await further instruction. This is the Model preparation phase.
Then register all your initial Mediators and let them set their view component listeners and fetch their proxy references. This is the View preparation phase.
You may choose to have your Mediators kick your Proxies into action at this time when they are registered, or you might have a Command that follows the View prep phase that goes and kicks off all the appropriate model calls to get data.
Now, when the calls come back from the Proxies, you already have the Mediators in place to listen for them and the view can organize itself accordingly.
Also if your startup is really complex with loading dependencies (i.e. can't load this till you've loaded that), you might look into either the Loadup utility or the StateMachine utility to help .
-=Cliff>
Logged
jaxim
Full Member
Posts: 22
Re: Should a Command add an event listener?
«
Reply #2 on:
April 12, 2010, 12:47:10 »
thanks. that helps a lot.
Logged
Pages: [
1
]
« previous
next »
Stack Overflow
GitHub
Linked In
Google Plus
Twitter
Powered by SMF 2.0.15
|
SMF © 2006-2007, Simple Machines LLC
|
Content © 2006-2018, Futurescale, Inc.
Loading...