The biggest things I need to do are update/change the
state of views
within the application. For instance, when a user has logged in
certain buttons get enabled, or certain panels become visible that
would not be so when the user is logged out.
I was thinking along the lines of using Commands, but I don't think
Commands should be concerned about the specific details (ie text
fields, buttons, etc) of a view. Using Commands would also entail
having to register all my views with a locator that would be used to
allow the Commands to find Views. Seems like a huge pain.
To me it seems much cleaner to allow the views to listen for certain
events (likely dispatched from a Manager) and then respond accordingly.
Derrick
--- In [EMAIL PROTECTED]ups.com,
"Dustin Mercer"
<dustin.mercer@...>
wrote:
>
> Out of curiosity, what is it you want to do when the login happens. I
> have only found a few things that were difficult to do from within a
> command. If you can tell me what you want to do, I can tell you what I
> have done in the past and how I accomplished it from within a command.
> In my Cairngorm trials, I had come to some of the same thinking as you
> described here, but I found that there were ways to accomplish it within
> the command instead of a management class. There were situations I
> chose to implement management classes though, for example, I had a class
> that managed all the media playing on a media player I am building...
> It just didn't feel right broken into commands, just didn't feel very
> cohesive, although accomplishable through commands, just felt better in
> a singleton class.... Especially since I was going to be using these
> same functions across many different commands and didn't want to rewrite
> the logic in each command.
>
>
>
> ________________________________
>
> From: [EMAIL PROTECTED]ups.com
[mailto:[EMAIL PROTECTED]ups.com]
On
> Behalf Of Derrick Grigg
> Sent: Wednesday, October 25, 2006 12:11 PM
> To: [EMAIL PROTECTED]ups.com
> Subject: [flexcoders] Cairngorm, dispatching application events and
> managing states
>
>
>
> Here's a question for any Cairngorm devotees to weigh in on.
>
> I have an application that has many seperate parts that function
> independently of each other. Each part uses the centralized Cairngorm
> fare (FrontController, ModelLocator, Commands etc). For most parts
> using the ModelLocator and bound properties (ie
> dataProvider={model.users}) works perfect for keeping everything
in
> order.
>
> One case where this seems to fall apart is when one part or the shell
> application needs to notify the other parts of something that has
> happened. For example, a user logs into the application. I can update
> the model.user to reflect a value object for the new user and the
> various components that need to update on this do, BUT, what to do
> when I need something programatic to occur in one of the parts.
>
> I have tried unsuccessfully to use the 'mx.binding' classes. I think
> the issue there is that when you initially set the binding it is set
> to a specific instance of an object (ie model.user). When the user
> logs in I typically completely replace the model.user with a new user
> instance, which kills the bindings. The only way around this is to
> never replace object instances in the model but rather update them.
> Thinking this through though, that seems like a ticking time bomb. Any
> accidental overwrite of a instance in the model and all the bindings
> falls apart.
>
> What I have done in past, pre Cairngorm, applications it to create
> Manager classes, based on the Singleton pattern, that can dispatch
> events, and perform logic that doesn't really belong in a command or
> business delegate. For example an ApplicationManager class that can
> dispatch 'loggedIn' and 'loggedOut' events. Any part of the
> application can register as a listener and act appropriately upon
> receiving the event.
>
> My question then (to get to the point), is using a Manager class like
> this considered a best practice in the Cairngorm framework (mindframe)
> or is there a better or more acceptable method of doing what I would
> like to accomplish?
>
> Thanks in advance for any feedback,
>
> Derrick
>