<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Handling deferred view component creation within the PureMVC framework</title>
	<atom:link href="http://www.cornilliac.com/blog/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cornilliac.com/blog/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/</link>
	<description>Rich Internet Applications and the systems that drive them</description>
	<pubDate>Fri, 21 Nov 2008 03:48:37 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: sitron</title>
		<link>http://www.cornilliac.com/blog/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/#comment-128</link>
		<dc:creator>sitron</dc:creator>
		<pubDate>Tue, 18 Mar 2008 08:25:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.cornilliac.com/blog/?p=44#comment-128</guid>
		<description>hi! it's me again. Just to inform you that i posted the same question on puremvc forum ("architecture" / topic: viewstack, deferred mediator creation).</description>
		<content:encoded><![CDATA[<p>hi! it&#8217;s me again. Just to inform you that i posted the same question on puremvc forum (&#8221;architecture&#8221; / topic: viewstack, deferred mediator creation).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sitron</title>
		<link>http://www.cornilliac.com/blog/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/#comment-123</link>
		<dc:creator>sitron</dc:creator>
		<pubDate>Mon, 17 Mar 2008 16:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.cornilliac.com/blog/?p=44#comment-123</guid>
		<description>hi!
very interesting...
but doesn't it add another problem? what if the command is passing data to the -still not created- mediator?
ie: view in a viewStack has a datagrid which on selection dispatches a notification (via its mediator) carrying dg selected data. Notification handles the viewStack change, but cannot pass the selected data to the new view as its mediator is still  not created. 
How do you deal with that? where would you store the transferred data while waiting on view creationComplete().
Sorry for the poor English.. hope it is understandable :)</description>
		<content:encoded><![CDATA[<p>hi!<br />
very interesting&#8230;<br />
but doesn&#8217;t it add another problem? what if the command is passing data to the -still not created- mediator?<br />
ie: view in a viewStack has a datagrid which on selection dispatches a notification (via its mediator) carrying dg selected data. Notification handles the viewStack change, but cannot pass the selected data to the new view as its mediator is still  not created.<br />
How do you deal with that? where would you store the transferred data while waiting on view creationComplete().<br />
Sorry for the poor English.. hope it is understandable <img src='http://www.cornilliac.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Cornilliac</title>
		<link>http://www.cornilliac.com/blog/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/#comment-13</link>
		<dc:creator>Tom Cornilliac</dc:creator>
		<pubDate>Sat, 26 Jan 2008 22:42:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.cornilliac.com/blog/?p=44#comment-13</guid>
		<description>Hi Cliff - You make a good point, I haven't given much thought to interrogating the view component to determine which mediator to use. I'm curious, which property are you using for the Switch? Do you use a public static const like name? 

Thanks for stopping by and adding!</description>
		<content:encoded><![CDATA[<p>Hi Cliff - You make a good point, I haven&#8217;t given much thought to interrogating the view component to determine which mediator to use. I&#8217;m curious, which property are you using for the Switch? Do you use a public static const like name? </p>
<p>Thanks for stopping by and adding!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cliff Hall</title>
		<link>http://www.cornilliac.com/blog/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/#comment-12</link>
		<dc:creator>Cliff Hall</dc:creator>
		<pubDate>Sat, 26 Jan 2008 20:08:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.cornilliac.com/blog/?p=44#comment-12</guid>
		<description>Hi Tom,

I generally defer the creation of the Mediator until its view component exists. The way you've done it here illustrates what what the ApplicationMediator's job usually ends up being. 

You can send a bubbling Event (no need for a custom event really) from any depth within your view hierarchy in the creationComplete for your new view component, and then grab it at the top with the ApplicationMediator. 

The event will have a reference to the component (event.target), which you can inspect any property of (such as id) in a switch statement, creating the appropriate Mediator depending upon the component and register it. 

-=Cliff&#62;</description>
		<content:encoded><![CDATA[<p>Hi Tom,</p>
<p>I generally defer the creation of the Mediator until its view component exists. The way you&#8217;ve done it here illustrates what what the ApplicationMediator&#8217;s job usually ends up being. </p>
<p>You can send a bubbling Event (no need for a custom event really) from any depth within your view hierarchy in the creationComplete for your new view component, and then grab it at the top with the ApplicationMediator. </p>
<p>The event will have a reference to the component (event.target), which you can inspect any property of (such as id) in a switch statement, creating the appropriate Mediator depending upon the component and register it. </p>
<p>-=Cliff&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Cornilliac</title>
		<link>http://www.cornilliac.com/blog/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/#comment-11</link>
		<dc:creator>Tom Cornilliac</dc:creator>
		<pubDate>Sat, 26 Jan 2008 18:26:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.cornilliac.com/blog/?p=44#comment-11</guid>
		<description>@Simeon - Thanks for stopping by man! I agree in that in PureMVC managing mediators can get a little bit complicated in larger apps, it's almost like the mediators are dancing with the display list and trying not to step on each other's toes (ok that was a lame analogy). When I first started with PureMVC this was not an issue as my app was on the smallish side, now that I'm working on a larger app I find myself thinking about this a lot. Here's couple of vague ideas on solving this problem.

I wonder if the Factory Pattern could apply here. Could I build a mediator factory (or would that be an Abstract Factory). The idea obviously is that the factory would handle all the dirty work.

Or maybe some sort of dependency injection where display objects are injected into mediators at runtime so when display objects are added to the display list the mediator is already bound to them. 

Food for thought anyway.</description>
		<content:encoded><![CDATA[<p>@Simeon - Thanks for stopping by man! I agree in that in PureMVC managing mediators can get a little bit complicated in larger apps, it&#8217;s almost like the mediators are dancing with the display list and trying not to step on each other&#8217;s toes (ok that was a lame analogy). When I first started with PureMVC this was not an issue as my app was on the smallish side, now that I&#8217;m working on a larger app I find myself thinking about this a lot. Here&#8217;s couple of vague ideas on solving this problem.</p>
<p>I wonder if the Factory Pattern could apply here. Could I build a mediator factory (or would that be an Abstract Factory). The idea obviously is that the factory would handle all the dirty work.</p>
<p>Or maybe some sort of dependency injection where display objects are injected into mediators at runtime so when display objects are added to the display list the mediator is already bound to them. </p>
<p>Food for thought anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Cornilliac</title>
		<link>http://www.cornilliac.com/blog/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/#comment-10</link>
		<dc:creator>Tom Cornilliac</dc:creator>
		<pubDate>Sat, 26 Jan 2008 18:05:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.cornilliac.com/blog/?p=44#comment-10</guid>
		<description>@Mike - There are at least a couple different ways that I can think of to trigger mediator removal when it's DisplayObject (component) is removed from the display list.

1. You could use a custom event subclass dispatched by the "removed" or "removedFromStage" event. The process here is almost exactly the same as in my post with the exception that you would call "facade.removeMediator(componentName)" from the listening mediator instead of creating a new mediator.

2. When you initially create the mediator, in the constructor method, add an event listener for the "removed" or "removedFromStage" event. Depending on which event you use your mediator will be notified just before it's about to be removed from the display list. You can then have your mediator destroy itself. 

I'd probably use method #2 most of the time. Method #1 is a bit overkill for most apps. Besides that method #2 requires your view component to dispatch one less event, which is always good.</description>
		<content:encoded><![CDATA[<p>@Mike - There are at least a couple different ways that I can think of to trigger mediator removal when it&#8217;s DisplayObject (component) is removed from the display list.</p>
<p>1. You could use a custom event subclass dispatched by the &#8220;removed&#8221; or &#8220;removedFromStage&#8221; event. The process here is almost exactly the same as in my post with the exception that you would call &#8220;facade.removeMediator(componentName)&#8221; from the listening mediator instead of creating a new mediator.</p>
<p>2. When you initially create the mediator, in the constructor method, add an event listener for the &#8220;removed&#8221; or &#8220;removedFromStage&#8221; event. Depending on which event you use your mediator will be notified just before it&#8217;s about to be removed from the display list. You can then have your mediator destroy itself. </p>
<p>I&#8217;d probably use method #2 most of the time. Method #1 is a bit overkill for most apps. Besides that method #2 requires your view component to dispatch one less event, which is always good.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simeon</title>
		<link>http://www.cornilliac.com/blog/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/#comment-9</link>
		<dc:creator>Simeon</dc:creator>
		<pubDate>Sat, 26 Jan 2008 03:51:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.cornilliac.com/blog/?p=44#comment-9</guid>
		<description>I am really glad that you are enjoying the framework. And this is an awesome example of a complex problem.  But seeing this reminds me of what I thought when I saw pureMVC for the first time.

"And people thought Cairngorm was complicated"

I think its great pureMVC jumps the gaps between Flex and flash and the server side stuff.  But I honestly cant imagine implementing all this stuff in a large application.

I am excited to hear more of your reviews of it.  I want to know if when you are done with a big project (something that warrants a heavy duty framework) if you feel all this stuff was worth while.

Thanks for the post!</description>
		<content:encoded><![CDATA[<p>I am really glad that you are enjoying the framework. And this is an awesome example of a complex problem.  But seeing this reminds me of what I thought when I saw pureMVC for the first time.</p>
<p>&#8220;And people thought Cairngorm was complicated&#8221;</p>
<p>I think its great pureMVC jumps the gaps between Flex and flash and the server side stuff.  But I honestly cant imagine implementing all this stuff in a large application.</p>
<p>I am excited to hear more of your reviews of it.  I want to know if when you are done with a big project (something that warrants a heavy duty framework) if you feel all this stuff was worth while.</p>
<p>Thanks for the post!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Huntington</title>
		<link>http://www.cornilliac.com/blog/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/#comment-8</link>
		<dc:creator>Mike Huntington</dc:creator>
		<pubDate>Sat, 26 Jan 2008 02:40:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.cornilliac.com/blog/?p=44#comment-8</guid>
		<description>One more question Tom (if you don't mind)...

What would be the best way to remove a mediator using the ComponentDestructionEvent... I'm trying to figure out how to get the ApplicationMediator to figure out what component just went out of view... and what mediator to take off.</description>
		<content:encoded><![CDATA[<p>One more question Tom (if you don&#8217;t mind)&#8230;</p>
<p>What would be the best way to remove a mediator using the ComponentDestructionEvent&#8230; I&#8217;m trying to figure out how to get the ApplicationMediator to figure out what component just went out of view&#8230; and what mediator to take off.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Huntington</title>
		<link>http://www.cornilliac.com/blog/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/#comment-7</link>
		<dc:creator>Mike Huntington</dc:creator>
		<pubDate>Fri, 25 Jan 2008 21:43:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.cornilliac.com/blog/?p=44#comment-7</guid>
		<description>That helps a lot and makes sense. Thanks!!</description>
		<content:encoded><![CDATA[<p>That helps a lot and makes sense. Thanks!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Cornilliac</title>
		<link>http://www.cornilliac.com/blog/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/#comment-6</link>
		<dc:creator>Tom Cornilliac</dc:creator>
		<pubDate>Fri, 25 Jan 2008 21:28:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.cornilliac.com/blog/?p=44#comment-6</guid>
		<description>Hi Mike - Sending a PureMVC notification from my view component to my view mediator wouldn't be a good idea at all. Doing so would require that my view component have knowledge of the framework which in turn would introduce coupling. Coupling in the view defeats the purpose of the view mediator. Using the Event class allows me to keep my component in the dark about it's implementation, thereby promoting reuse. 

Now I would definitely use a Command/Notification setup to perform work  on the Model from the View or maybe even within the View if the work was complicated enough. Hope this helps.</description>
		<content:encoded><![CDATA[<p>Hi Mike - Sending a PureMVC notification from my view component to my view mediator wouldn&#8217;t be a good idea at all. Doing so would require that my view component have knowledge of the framework which in turn would introduce coupling. Coupling in the view defeats the purpose of the view mediator. Using the Event class allows me to keep my component in the dark about it&#8217;s implementation, thereby promoting reuse. </p>
<p>Now I would definitely use a Command/Notification setup to perform work  on the Model from the View or maybe even within the View if the work was complicated enough. Hope this helps.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
