<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Return Value of Function as items Pattern</title>
	<atom:link href="http://blog.extjs.eu/patterns/code-patterns/return-value-of-function-as-items-pattern/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.extjs.eu/patterns/code-patterns/return-value-of-function-as-items-pattern/</link>
	<description>For good of all productive developers</description>
	<lastBuildDate>Sun, 05 Feb 2012 09:37:22 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: thezver</title>
		<link>http://blog.extjs.eu/patterns/code-patterns/return-value-of-function-as-items-pattern/comment-page-1/#comment-3689</link>
		<dc:creator>thezver</dc:creator>
		<pubDate>Wed, 03 Mar 2010 11:46:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.extjs.eu/?p=11#comment-3689</guid>
		<description>the difference is scope : in case you need to refer to properties/methods of the class itself (`this`) inside the function.
also, i think it\&#039;s a good practice to NOT use inline functions (closures) this way, but to refer to defined methods of the class, or to \&#039;helper\&#039; methods.
correct me if i\&#039;m wrong .</description>
		<content:encoded><![CDATA[<p>the difference is scope : in case you need to refer to properties/methods of the class itself (`this`) inside the function.<br />
also, i think it\&#8217;s a good practice to NOT use inline functions (closures) this way, but to refer to defined methods of the class, or to \&#8217;helper\&#8217; methods.<br />
correct me if i\&#8217;m wrong .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zeruyo</title>
		<link>http://blog.extjs.eu/patterns/code-patterns/return-value-of-function-as-items-pattern/comment-page-1/#comment-1768</link>
		<dc:creator>zeruyo</dc:creator>
		<pubDate>Wed, 26 Aug 2009 06:17:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.extjs.eu/?p=11#comment-1768</guid>
		<description>I don\&#039;t understand what the difference is with

items:function()
{
var items[];
.
.
.
return items;
}()</description>
		<content:encoded><![CDATA[<p>I don\&#8217;t understand what the difference is with</p>
<p>items:function()<br />
{<br />
var items[];<br />
.<br />
.<br />
.<br />
return items;<br />
}()</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Saki</title>
		<link>http://blog.extjs.eu/patterns/code-patterns/return-value-of-function-as-items-pattern/comment-page-1/#comment-133</link>
		<dc:creator>Saki</dc:creator>
		<pubDate>Mon, 26 May 2008 11:18:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.extjs.eu/?p=11#comment-133</guid>
		<description>@Lucian

Exactly! I see that you grasped it fully. You can use same pattern also for &lt;i&gt;items&lt;/i&gt; array if you need to.</description>
		<content:encoded><![CDATA[<p>@Lucian</p>
<p>Exactly! I see that you grasped it fully. You can use same pattern also for <i>items</i> array if you need to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lucian</title>
		<link>http://blog.extjs.eu/patterns/code-patterns/return-value-of-function-as-items-pattern/comment-page-1/#comment-132</link>
		<dc:creator>Lucian</dc:creator>
		<pubDate>Mon, 26 May 2008 10:42:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.extjs.eu/?p=11#comment-132</guid>
		<description>A good example on how to use this pattern:
&lt;pre lang=&quot;javascript&quot;&gt;
{
     xtype: &#039;combo&#039;
    ,fieldLabel: &#039;Combobox field label&#039;
    ,width:186
    ,typeAhead: true
    ,displayField: &#039;value&#039;
    ,mode: &#039;local&#039;
    ,value: new Date().format(&#039;Y&#039;)
    ,triggerAction: &#039;all&#039;
    ,hideOnSelect:false
    ,emptyText:&#039;Select year...&#039;
    ,store: (function(){
        var years = [];         
        var dt = new Date();
        for(var i=1900; i &lt;= dt.format(&#039;Y&#039;); i++){
            years.push(i);
        }    
        return years;
    }).createDelegate(this)()
}

&lt;/pre&gt;
That code will render a combobox for selecting one year between 1900 and the current year, basically an &quot;year selector&quot;.</description>
		<content:encoded><![CDATA[<p>A good example on how to use this pattern:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
     xtype<span style="color: #339933;">:</span> <span style="color: #3366CC;">'combo'</span>
    <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Combobox field label'</span>
    <span style="color: #339933;">,</span>width<span style="color: #339933;">:</span><span style="color: #CC0000;">186</span>
    <span style="color: #339933;">,</span>typeAhead<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span>
    <span style="color: #339933;">,</span>displayField<span style="color: #339933;">:</span> <span style="color: #3366CC;">'value'</span>
    <span style="color: #339933;">,</span>mode<span style="color: #339933;">:</span> <span style="color: #3366CC;">'local'</span>
    <span style="color: #339933;">,</span>value<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">format</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Y'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">,</span>triggerAction<span style="color: #339933;">:</span> <span style="color: #3366CC;">'all'</span>
    <span style="color: #339933;">,</span>hideOnSelect<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span>
    <span style="color: #339933;">,</span>emptyText<span style="color: #339933;">:</span><span style="color: #3366CC;">'Select year...'</span>
    <span style="color: #339933;">,</span>store<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> years <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>         
        <span style="color: #003366; font-weight: bold;">var</span> dt <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">1900</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> dt.<span style="color: #660066;">format</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Y'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            years.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>    
        <span style="color: #000066; font-weight: bold;">return</span> years<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">createDelegate</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>That code will render a combobox for selecting one year between 1900 and the current year, basically an &#8220;year selector&#8221;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

