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
command modifies viewComponent??
Pages: [
1
]
« previous
next »
Author
Topic: command modifies viewComponent?? (Read 9711 times)
marcink
Jr. Member
Posts: 13
command modifies viewComponent??
«
on:
December 24, 2008, 02:49:35 »
hi all,
is it allowed to modify a viewComponent directly from a command?
i have a MacroAsyncCommand with three AsyncCommands: FadeOut, Update and FadeIn.
each of the subcommands modifies the view directly.
i know i could make it like: call 1st command from mediator, when 1st command sends notification that its finished, mediator modifies the view, then calls the 2nd command... and so on.
but with this, i would add lots of constants to the app.
i would like to know, if the first approach is allowed or not.
thanks!!
Logged
puremvc
Global Moderator
Hero Member
Posts: 2871
Re: command modifies viewComponent??
«
Reply #1 on:
December 25, 2008, 06:20:01 »
Sometimes there are situations that require the view component to be updated in the way that you describe. In these cases, you can retrieve the mediator, and access its view component. You have to make the typed getter public on the mediator.
The only problem with this and why it is cautioned against is that it spreads around knowledge of the view component, such that if that component is modified, multiple actors may need to be refactored. This is why the mediator is generally the only point of contact with that component.
Ways to reduce code smell when you do this are to cleanly implement your 'API' of props and methods for the component so as to encapsulate as much of its internal implementation (which you should be doing as a matter of course to protect the mediator, but now its even more important). Consider making the component implement an interface and only make calls against the interface (i.e. The typed getter returns an interface type rather than a class).
-=Cliff>
Logged
marcink
Jr. Member
Posts: 13
Re: command modifies viewComponent??
«
Reply #2 on:
December 25, 2008, 12:28:02 »
hi cliff,
thanks for the answer...
i'm quite new to patterns, so sometimes i'm not very confident hot to use it...
anyway, thanks!
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...