<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en-US">
  <id>tag:robertdougan.com,2005:/feed</id>
  <link rel="alternate" type="text/html" href="http://robertdougan.com" />
  
  <title>Robert Dougan</title>
  <updated>2012-02-27T02:00:52+00:00</updated>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/robertdougan/blog" /><feedburner:info uri="robertdougan/blog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
    <id>tag:robertdougan.com,2005:Post/12</id>
    <published>2012-02-04T08:03:48Z</published>
    <updated>2012-02-06T06:13:06Z</updated>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/robertdougan/blog/~3/UMPDKuActps/veggie-meals-for-ipad" />
    <title>Veggie Meals for iPad</title>
    <content type="html">&lt;p&gt;Over the past few months I&amp;#39;ve been working with some incredibly talented people to create &lt;a href="http://veggiemealsapp.com"&gt;Veggie Meals for iPad&lt;/a&gt;. This is the first iOS application I have worked on and it has been a lot of fun.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://maxthemes.com/"&gt;Max Rudberg&lt;/a&gt; and &lt;a href="http://jennysunden.tumblr.com/"&gt;Jenny Sundén&lt;/a&gt; contacted me after I reached out to Max on Twitter about needing an iOS developer. I didn&amp;#39;t have much experience at the time (I still don&amp;#39;t) but I thought &lt;em&gt;&amp;quot;what the hell&amp;quot;&lt;/em&gt; and replied anyway. After a quick call, it was obvious that they had both spent a lot of time and effort on the app; the UX, the design, and the content. I couldn&amp;#39;t say no.&lt;/p&gt;

&lt;p&gt;After several months of hard work, the result is a beautifully crafted and designed recipe app that contains 55 easy to cook recipes. A lot of attention to detail has been put into every aspect of the application; the simple but &lt;em&gt;tasty&lt;/em&gt; recipes (by Viktor Sundén), the &lt;em&gt;divine&lt;/em&gt; photography (by Anna-Maria Will), the &lt;em&gt;pixel perfect&lt;/em&gt; UX and design (&lt;a href="http://maxthemes.com/"&gt;Max Rudberg&lt;/a&gt; and &lt;a href="http://jennysunden.tumblr.com/"&gt;Jenny Sundén&lt;/a&gt;) and of course the clean code that no one sees (me!).&lt;/p&gt;

&lt;p&gt;Working with such &lt;em&gt;talented&lt;/em&gt; people like &lt;a href="http://jennysunden.tumblr.com/"&gt;Jenny&lt;/a&gt; and &lt;a href="http://maxthemes.com/"&gt;Max&lt;/a&gt; has been a pleasure, and I can&amp;#39;t wait to collaborate with them again in the future.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://cl.ly/DwF8/veggiemeals-press-eng.jpg" alt="Download now!"&gt;&lt;/p&gt;

&lt;p&gt;So what are you waiting for? &lt;a href="http://itunes.apple.com/app/veggie-meals/id495582698?mt=8"&gt;Download&lt;/a&gt; the app now!&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/robertdougan/blog/~4/UMPDKuActps" height="1" width="1"/&gt;</content>
    <updated>2012-02-06T06:13:06Z</updated>
    <published>2012-02-06T06:13:06Z</published>
  <feedburner:origLink>http://robertdougan.com/posts/veggie-meals-for-ipad</feedburner:origLink></entry>
  <entry>
    <id>tag:robertdougan.com,2005:Post/11</id>
    <published>2011-12-19T18:24:51Z</published>
    <updated>2012-02-05T22:40:24Z</updated>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/robertdougan/blog/~3/Ce2lOf1huJU/taking-advantage-of-componentview-in-sencha-touch-2" />
    <title>Taking Advantage of ComponentView in Sencha Touch 2</title>
    <content type="html">&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This blog post is redundant and no longer applies to latest version of Sencha Touch 2. Please read the official guide on the &lt;a href="http://docs.sencha.com/touch/2-0/#!/guide/dataview"&gt;Sencha Touch 2 Documentation&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The GitHub project &lt;em&gt;has&lt;/em&gt; been updated to the latest version of Sencha Touch 2. It is available &lt;a href="https://github.com/senchalabs/component-dataview-example"&gt;here&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sencha Touch 2 is still in preview (at the time of writing this), and although the release has been focused on performance improvements, there are a few new components that can be incredibly useful. One of the new components I love is &lt;code&gt;Ext.dataview.ComponentView&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;What is it?&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Ext.dataview.ComponentView&lt;/code&gt; is basically a &lt;code&gt;Ext.DataView&lt;/code&gt;. You bind a store to it and it shows it in a list-like fashion. However with ComponentView, each list item can be a &lt;em&gt;component&lt;/em&gt;. As a result, the possibilities are incredible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Please be aware that the following API may change before the Sencha Touch 2.0 final release.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;Example&lt;/h2&gt;

&lt;p&gt;I&amp;#39;ve put together a simple &lt;strong&gt;MVC&lt;/strong&gt; application to show you how &lt;code&gt;Ext.dataview.ComponentView&lt;/code&gt; works. The source can be found &lt;a href="https://github.com/senchalabs/component-dataview-example"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Oh, and our example application is going to have some kittens in it. &lt;em&gt;NICE&lt;/em&gt;. So let&amp;#39;s get started!&lt;/p&gt;

&lt;h2&gt;Structure&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;MVC&lt;/strong&gt; structure in Sencha Touch 2 is similar to Ext JS 4. You have an few important parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;app&amp;#47;&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;controller&amp;#47;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;model&amp;#47;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;store&amp;#47;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;view&amp;#47;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;resources&amp;#47;&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;css&amp;#47;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sass&amp;#47;&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;config.rb&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;style.scss&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;lib&amp;#47;&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;touch2&amp;#47;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;index.html&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;index-debug.html&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I&amp;#39;m not going to explain what this means here. There is a great post on the subject &lt;a href="http://blog.falafel.com/blogs/basememara/11-12-15/Building_a_Mobile_Web_App_using_Sencha_Touch_2_and_MVC.aspx"&gt;here&lt;/a&gt; and I&amp;#39;m sure there will be several guides in the future when Sencha Touch 2 is released.&lt;/p&gt;

&lt;h3&gt;Your Application&lt;/h3&gt;

&lt;h4&gt;app.js&lt;/h4&gt;

&lt;p&gt;We need to define an &lt;code&gt;app.js&lt;/code&gt; file so Sencha Touch knows we are creating an application. It is very simple to put together.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Ext.Loader.setConfig({enabled: true});
Ext.Loader.setPath(&amp;#39;Ext&amp;#39;, &amp;#39;lib&amp;#47;touch2&amp;#47;src&amp;#39;);

Ext.application({
    name: &amp;#39;Example&amp;#39;,

    controllers: [&amp;#39;Application&amp;#39;],
    views: [&amp;#39;Main&amp;#39;],

    launch: function() {
        Ext.Viewport.add({
            xclass: &amp;#39;Example.view.Main&amp;#39;
        });
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Enable &lt;code&gt;Ext.Loader&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Set the path location of the &lt;code&gt;Ext.*&lt;/code&gt; class namespace.&lt;/li&gt;
&lt;li&gt;Define our application.&lt;/li&gt;
&lt;li&gt;Give it a &lt;code&gt;name&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Give it the name of our only controller, &lt;code&gt;Application&lt;/code&gt; (we don&amp;#39;t have to use the full namespace).&lt;/li&gt;
&lt;li&gt;Give it the name of our only view, &lt;code&gt;Main&lt;/code&gt; (we don&amp;#39;t need the full namespace here either);&lt;/li&gt;
&lt;li&gt;Define a &lt;code&gt;launch&lt;/code&gt; method which added &lt;code&gt;Example.view.Main&lt;/code&gt; as an item to &lt;code&gt;Ext.Viewport&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Model&lt;/h3&gt;

&lt;h4&gt;app&amp;#47;model&amp;#47;Kitten.js&lt;/h4&gt;

&lt;p&gt;Our example is going to have lots of kittens in it which will come from a store, so we obviously need a &lt;code&gt;Kitten&lt;/code&gt; model.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Ext.define(&amp;#39;Example.model.Kitten&amp;#39;, {
    extend: &amp;#39;Ext.data.Model&amp;#39;,

    fields: [
        &amp;quot;name&amp;quot;,
        &amp;quot;image&amp;quot;,
        { name: &amp;quot;cuteness&amp;quot;, type: &amp;#39;int&amp;#39; }
    ]
});
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Define our model and extend &lt;code&gt;Ext.data.Model&lt;/code&gt;. Notice how it uses the &lt;code&gt;Example&lt;/code&gt; namespace.&lt;/li&gt;
&lt;li&gt;Give the model some &lt;code&gt;fields&lt;/code&gt; (one of which is an &lt;em&gt;integer&lt;/em&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Store&lt;/h3&gt;

&lt;h4&gt;app&amp;#47;store&amp;#47;Kittens.js&lt;/h4&gt;

&lt;p&gt;Now we have a &lt;code&gt;Kitten&lt;/code&gt; model, we need to setup a store to use that model and give it some data. Simple.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Ext.define(&amp;#39;Example.store.Kittens&amp;#39;, {
    extend: &amp;#39;Ext.data.Store&amp;#39;,
    model: &amp;#39;Example.model.Kitten&amp;#39;,

    data: [
        {
            name: &amp;#39;Running kitten&amp;#39;,
            image: &amp;#39;data&amp;#47;images&amp;#47;kitten1.jpg&amp;#39;,
            cuteness: 70
        },
        {
            name: &amp;#39;Spreading legs kitten&amp;#39;,
            image: &amp;#39;data&amp;#47;images&amp;#47;kitten2.jpg&amp;#39;,
            cuteness: 90
        },
        {
            name: &amp;#39;Tongue kitten&amp;#39;,
            image: &amp;#39;data&amp;#47;images&amp;#47;kitten3.jpg&amp;#39;,
            cuteness: 70
        },
        {
            name: &amp;#39;Ginger kitten&amp;#39;,
            image: &amp;#39;data&amp;#47;images&amp;#47;kitten4.jpg&amp;#39;,
            cuteness: 80
        },
        {
            name: &amp;#39;Kitten friends&amp;#39;,
            image: &amp;#39;data&amp;#47;images&amp;#47;kitten5.jpg&amp;#39;,
            cuteness: 20
        },
        {
            name: &amp;#39;Milk kitten&amp;#39;,
            image: &amp;#39;data&amp;#47;images&amp;#47;kitten6.jpg&amp;#39;,
            cuteness: 50
        }
    ]
});
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Define our store and make it extend &lt;code&gt;Ext.data.Store&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Give it a model of &lt;code&gt;Example.model.Kitten&lt;/code&gt; (which we defined above).&lt;/li&gt;
&lt;li&gt;Give it some fake &lt;code&gt;data&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Controller&lt;/h3&gt;

&lt;h4&gt;app&amp;#47;controller&amp;#47;Application.js&lt;/h4&gt;

&lt;p&gt;We only have one controller in our application, and it isn&amp;#39;t going to do much. For now, we just need to include our &lt;code&gt;Kittens&lt;/code&gt; store and the &lt;code&gt;KittensList&lt;/code&gt; view (which we&amp;#39;ll create later).&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Ext.define(&amp;#39;Example.controller.Application&amp;#39;, {
    extend: &amp;#39;Ext.app.Controller&amp;#39;,

    stores: [&amp;#39;Kittens&amp;#39;],
    views: [&amp;#39;KittensList&amp;#39;]
});
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Define our controller and make it extend &lt;code&gt;Ext.app.Controller&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Give it our store (notice how we don&amp;#39;t have to add &lt;code&gt;Examples.store.&lt;/code&gt;, it&amp;#39;s done automatically).&lt;/li&gt;
&lt;li&gt;Give it our view (no namespace just like above).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Views&lt;/h3&gt;

&lt;h4&gt;app&amp;#47;view&amp;#47;Main.js&lt;/h4&gt;

&lt;p&gt;We need to add a global view for application, which basically acts as a Viewport. We shall call this &lt;code&gt;Main.js&lt;/code&gt;. There isn&amp;#39;t much to it.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Ext.define(&amp;#39;Example.view.Main&amp;#39;, {
    extend: &amp;#39;Ext.Container&amp;#39;,

    requires: [&amp;#39;Example.view.KittensList&amp;#39;],

    config: {
        layout: &amp;#39;fit&amp;#39;,

        items: [
            { xclass: &amp;#39;Example.view.KittensList&amp;#39; }
        ]
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Define our view and make it extend &lt;code&gt;Ext.Container&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Give it some &lt;code&gt;requires&lt;/code&gt; for our &lt;code&gt;Example.view.KittensList&lt;/code&gt; component (defined next).&lt;/li&gt;
&lt;li&gt;Give it a &lt;em&gt;fit&lt;/em&gt; &lt;code&gt;layout&lt;/code&gt; so the list stretches to the size of this container.&lt;/li&gt;
&lt;li&gt;Add the &lt;code&gt;Example.view.KittensList&lt;/code&gt; as a child item of the container.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;app&amp;#47;view&amp;#47;KittensList.js&lt;/h4&gt;

&lt;p&gt;The first view we will create is &lt;code&gt;Example.view.KittensList&lt;/code&gt;. It is going to extend &lt;code&gt;Ext.dataview.ComponentView&lt;/code&gt; and it&amp;#39;s not gonna do much.&lt;/p&gt;

&lt;p&gt;So here&amp;#39;s the code:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Ext.define(&amp;#39;Example.view.KittensList&amp;#39;, {
    extend: &amp;#39;Ext.dataview.ComponentView&amp;#39;,
    xtype: &amp;#39;kittenlist&amp;#39;,

    requires: [&amp;#39;Example.view.KittensListItem&amp;#39;],

    config: {
        cls: &amp;#39;kitten-list&amp;#39;,
        store: &amp;#39;Kittens&amp;#39;,
        defaultType: &amp;#39;kittenslistitem&amp;#39;
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;We define the class and extend &lt;code&gt;Ext.dataview.ComponentView&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Add a custom &lt;code&gt;cls&lt;/code&gt; so we can make it pretty.&lt;/li&gt;
&lt;li&gt;Give it a &lt;code&gt;store&lt;/code&gt; (&lt;code&gt;Kittens&lt;/code&gt; to be exact).&lt;/li&gt;
&lt;li&gt;Give it a &lt;code&gt;defaultType&lt;/code&gt; which is the default xtype of any components being added to the list.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;app&amp;#47;view&amp;#47;KittensListItem.js&lt;/h4&gt;

&lt;p&gt;This view is going to be used as the &lt;code&gt;defaultType&lt;/code&gt; of the above &lt;code&gt;Example.view.KittensList&lt;/code&gt;. There is a little bit of magic that goes on in this class, so I will go through it a little slower. Sorry about it&amp;#39;s length (&lt;em&gt;that&amp;#39;s what she said&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;So first up, the base of the class:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Ext.define(&amp;#39;Example.view.KittensListItem&amp;#39;, {
    extend: &amp;#39;Ext.dataview.DataItem&amp;#39;,
    xtype : &amp;#39;kittenslistitem&amp;#39;,

    config: {
        cls: &amp;#39;kitten-list-item&amp;#39;
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;We extend &lt;code&gt;Ext.dataview.DataItem&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Give it an &lt;code&gt;xtype&lt;/code&gt; (which we are using above).&lt;/li&gt;
&lt;li&gt;Add the &lt;code&gt;cls&lt;/code&gt; config so we can style it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we have the basics of the application put together now. If you open it up in a browser, it will show a list with a bunch of items. Unfortunately, because the ListItem has no content, it will be blank.&lt;/p&gt;

&lt;p&gt;So what we gotta do to make it display?&lt;/p&gt;

&lt;h5&gt;New Configurations&lt;/h5&gt;

&lt;p&gt;First up, we need to add new configurations for each of the different views we are going to have in each list item. To do this, we need to know what it is going to look like.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/1A150o3r0r0035172D1O/Screen%20Shot%202011-12-15%20at%207.45.26%20PM.png" alt="List Item Template"&gt;&lt;/p&gt;

&lt;p&gt;So you can see we are going to show an image of the kitten, the name of the kitten and a slider which will show the cuteness of the kitten; all inside the &lt;code&gt;Examples.view.KittensListItem&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So let&amp;#39;s go ahead and add a configuration for each one of these components:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;config: {
    ...

    image: true,

    name: {
        cls: &amp;#39;x-name&amp;#39;,
        flex: 1
    },

    slider: {
        flex: 2
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;image&lt;/code&gt; configuration will be transformed into a &lt;code&gt;Ext.Img&lt;/code&gt; component.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;name&lt;/code&gt; configuration will be transformed into a &lt;code&gt;Ext.Component&lt;/code&gt; component.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;slider&lt;/code&gt; configuration will be transformed into a &lt;code&gt;Ext.slider.Slider&lt;/code&gt; component.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So how do these configurations get transformed?&lt;/p&gt;

&lt;p&gt;What we need to do is add apply and update methods for each of this configurations. Let me show you the code.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;applyImage: function(config) {
    return Ext.factory(config, Ext.Img, this.getImage());
},

updateImage: function(newImage, oldImage) {
    if (newImage) {
        this.add(newImage);
    }

    if (oldImage) {
        this.remove(oldImage);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The apply method (which is called when &lt;code&gt;setImage&lt;/code&gt; is called) will use &lt;code&gt;Ext.factory&lt;/code&gt; to take the passed configuration, and any existing instance (using &lt;code&gt;getImage&lt;/code&gt;) and return a new instance of the type passed (in this case, &lt;code&gt;Ext.Img&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Then in our &lt;code&gt;updateImage&lt;/code&gt; method, we simply add the &lt;code&gt;newImage&lt;/code&gt; into the list item, and remove &lt;code&gt;oldImage&lt;/code&gt; item if one exists.&lt;/p&gt;

&lt;p&gt;Make sense? If not, take a look at the &lt;a href="http://docs.sencha.com/touch/2-0/#!/guide/class_system"&gt;Class System&lt;/a&gt; guide.&lt;/p&gt;

&lt;p&gt;We need to now do the same for the other two configurations:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;applyName: function(config) {
    return Ext.factory(config, Ext.Component, this.getName());
},

updateName: function(newName, oldName) {
    if (newName) {
        this.add(newName);
    }

    if (oldName) {
        this.remove(oldName);
    }
},

applySlider: function(config) {
    return Ext.factory(config, Ext.slider.Slider, this.getSlider());
},

updateSlider: function(newSlider, oldSlider) {
    if (newSlider) {
        this.add(newSlider);
    }

    if (oldSlider) {
        this.remove(oldSlider);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The same idea again, only using &lt;code&gt;Ext.Component&lt;/code&gt; and &lt;code&gt;Ext.slider.Slider&lt;/code&gt; as the component of choice.&lt;/p&gt;

&lt;h5&gt;Requires&lt;/h5&gt;

&lt;p&gt;We are now using the &lt;code&gt;Ext.Img&lt;/code&gt; and &lt;code&gt;Ext.slider.Slider&lt;/code&gt; components in our list item, so we must require those classes so when this list item class is loaded, the required class are also loaded.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;... 

requires: [
    &amp;#39;Ext.Img&amp;#39;,
    &amp;#39;Ext.slider.Slider&amp;#39;
]

...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Note: this is&lt;/em&gt; &lt;strong&gt;not&lt;/strong&gt; &lt;em&gt;inside the &lt;code&gt;config&lt;/code&gt; block&lt;/em&gt;.&lt;/p&gt;

&lt;h5&gt;Layout&lt;/h5&gt;

&lt;p&gt;Now we have items inside each list item, we must have them displayed properly. For this, we use the &lt;code&gt;layout&lt;/code&gt; configuration and set it to &lt;em&gt;hbox&lt;/em&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;config: {
    ...

    layout: {
        type: &amp;#39;hbox&amp;#39;,
        align: &amp;#39;center&amp;#39;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h5&gt;dataMap&lt;/h5&gt;

&lt;p&gt;This is were the magic begins.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;code&gt;dataMap&lt;/code&gt; configuration allows you to call functions with a &lt;strong&gt;value&lt;/strong&gt; of a field, on functions of your &lt;em&gt;list item&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Stumped? Let&amp;#39;s look at the code:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;config: {
    ...

    dataMap: {
        getImage: {
            setSrc: &amp;#39;image&amp;#39;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So you can see we defined the &lt;code&gt;dataMap&lt;/code&gt; configuration. It is just an object with a few keys and values. The &lt;em&gt;key&lt;/em&gt; of each item is the &lt;em&gt;method name&lt;/em&gt; you want to call. This method name &lt;em&gt;must&lt;/em&gt; return something, and then with that returned value, it will call the &lt;em&gt;key&lt;/em&gt; of the inner object with the value (which is a field name).&lt;/p&gt;

&lt;p&gt;So with the above code, this is what happens when the record of the list item is updated:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We get the new &lt;code&gt;record&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;We then call: &lt;code&gt;listItem.getImage().setSrc(record.get(&amp;#39;image&amp;#39;));&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understand now? Good job!&lt;/p&gt;

&lt;p&gt;So now we have figured this out, we need to add the correct &lt;code&gt;dataMap&lt;/code&gt; for each of the fields so the whole item has the correct look.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;config: {
    ...

    dataMap: {
        getImage: {
            setSrc: &amp;#39;image&amp;#39;
        },

        getName: {
            setHtml: &amp;#39;name&amp;#39;
        },

        getSlider: {
            setValue: &amp;#39;cuteness&amp;#39;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Custom CSS&lt;/h3&gt;

&lt;p&gt;For this example I have used &lt;a href="https://github.com/senchalabs/component-dataview-example/blob/master/resources/sass/style.scss"&gt;SCSS&lt;/a&gt; to make it look a little better. &lt;/p&gt;

&lt;p&gt;As always, there isn&amp;#39;t much too it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;#47;&amp;#47;include sencha touch
@import &amp;#39;sencha-touch&amp;#47;default&amp;#47;all&amp;#39;;

&amp;#47;&amp;#47;include layout and form parts of sencha touch
@include sencha-layout;
@include sencha-form-sliders;

&amp;#47;&amp;#47;define a variable so we can have consistant padding throughout the app
$list-padding: .7em;

&amp;#47;&amp;#47;body background
body {
    background: #eee;
}

&amp;#47;&amp;#47;kitten list styling
.kitten-list {
    .x-dataview-inner {
        padding: $list-padding;
    }

    &amp;#47;&amp;#47;kitten list item styling
    .kitten-list-item {
        padding: $list-padding&amp;#47;2;
        background: #fff;
        border: 1px solid #ccc;
        border-bottom-width: 0;

        &amp;#47;&amp;#47;add rounded corners to the last item
        &amp;amp;:last-child {
            border-bottom-width: 1px;
            @include border-bottom-radius($list-padding&amp;#47;2);
        }
    }

    &amp;#47;&amp;#47;add rounded corners to the first item
    .x-mask + .kitten-list-item {
        @include border-top-radius($list-padding&amp;#47;2);
    }

    .kitten-list-item .x-img {
        background: #eee;
        background-size: cover;
        background-position: center center;

        @include border-radius($list-padding&amp;#47;2);

        width: 80px;
        height: 80px;
    }

    .kitten-list-item .x-name {
        padding: 0 $list-padding&amp;#47;2;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I&amp;#39;ve added inline comments to explain everything.&lt;/p&gt;

&lt;h4&gt;Before&lt;/h4&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/3s3D2x443q1Z1q1G2r3N/Screen%20Shot%202011-12-15%20at%208.15.12%20PM.png" alt="Before"&gt;&lt;/p&gt;

&lt;h4&gt;After&lt;/h4&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/0D0y3h2a133T2Q3P1h43/Screen%20Shot%202011-12-15%20at%208.15.23%20PM.png" alt="After"&gt;&lt;/p&gt;

&lt;h3&gt;What if we want to know when the slider changed?&lt;/h3&gt;

&lt;p&gt;Each list item now has a slider, of which the value can change. So what if you want to know when that happens? Doing this is pretty simple.&lt;/p&gt;

&lt;p&gt;Let&amp;#39;s go back to our controller.&lt;/p&gt;

&lt;h4&gt;app&amp;#47;controller&amp;#47;Application.js&lt;/h4&gt;

&lt;p&gt;What we want to do is override our &lt;code&gt;init&lt;/code&gt; method in our controller, so we can call &lt;code&gt;control&lt;/code&gt; with any listeners we have on our views.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;init: function() {
    this.control({
        &amp;#39;kittenslistitem slider&amp;#39;: {
            change: this.onCutenessChange
        }
    });
},

onCutenessChange: function(slider, value) {
    &amp;#47;&amp;#47;we should do something here
    console.log(&amp;#39;onCutenessChange&amp;#39;, value);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;We define the &lt;code&gt;init&lt;/code&gt; method&lt;/li&gt;
&lt;li&gt;We call the &lt;code&gt;control&lt;/code&gt; method, which you can pass a ComponentQuery and then which events you want to listen to (&lt;code&gt;change&lt;/code&gt; in this case), and then we give it a method to call.&lt;/li&gt;
&lt;li&gt;Define the &lt;code&gt;onCutenessChange&lt;/code&gt; method so we know something happens.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now if you reload and move one of the sliders, you will get a billion logs of value being changed. &lt;em&gt;NICE.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;Incredible, but be careful&lt;/h2&gt;

&lt;p&gt;As you can see, the flexibility and power available when using the new &lt;code&gt;Ext.dataview.ComponentView&lt;/code&gt; is incredible. This can be so very useful in many, many occasions.&lt;/p&gt;

&lt;p&gt;But it&amp;#39;s not all good..&lt;/p&gt;

&lt;p&gt;So let&amp;#39;s say we created this same example with a &lt;code&gt;Ext.DataView&lt;/code&gt; (but without the slider). In total, your application would have &lt;strong&gt;2&lt;/strong&gt; component; &lt;code&gt;Main.js&lt;/code&gt; and &lt;code&gt;KittensList.js&lt;/code&gt;. With &lt;code&gt;Ext.dataview.ComponentView&lt;/code&gt; though, that number goes up to &lt;strong&gt;20&lt;/strong&gt;, and that is with only &lt;strong&gt;6&lt;/strong&gt; rows in the store. This can drastically increase memory usage and the amount of DOM generated for all your list items. So you &lt;em&gt;must&lt;/em&gt; watch out when using this.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;If you have any issues, feel free to comment below; but only after you checkout the source over on &lt;a href="https://github.com/senchalabs/component-dataview-example"&gt;GitHub&lt;/a&gt; (I&amp;#39;ve included &lt;em&gt;loads&lt;/em&gt; of documentation in the actual source code).&lt;/p&gt;

&lt;p&gt;That will be all.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/robertdougan/blog/~4/Ce2lOf1huJU" height="1" width="1"/&gt;</content>
    <updated>2012-02-05T22:40:24Z</updated>
    <published>2012-02-05T22:40:24Z</published>
  <feedburner:origLink>http://robertdougan.com/posts/taking-advantage-of-componentview-in-sencha-touch-2</feedburner:origLink></entry>
  <entry>
    <id>tag:robertdougan.com,2005:Post/9</id>
    <published>2011-12-10T02:35:39Z</published>
    <updated>2012-01-06T20:47:28Z</updated>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/robertdougan/blog/~3/IS-jCTvVo4s/packaging-your-sencha-touch-2-application-using-the-sencha-sdk-tools" />
    <title>Packaging your Sencha Touch 2 Application using the Sencha SDK Tools</title>
    <content type="html">&lt;p&gt;Once your application is ready for production, you should compile all your JavaScript files into one. There are two reasons for this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There will only be one request for your Application. Having several file requests in a mobile browser can dramatically reduce your application&amp;#39;s loading time.&lt;/li&gt;
&lt;li&gt;You can compress your JavaScript, so you can cut down on the final file size.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sencha have their SDK Tools product which allows you to do just that. Not only that, but the SDK Tools will allow you to only include parts of Sencha Touch your application actually uses. In most cases, this could help you reduce your application file size by hundreds of kilobytes, which is huge!&lt;/p&gt;

&lt;p&gt;So lets get started.&lt;/p&gt;

&lt;h2&gt;Installation&lt;/h2&gt;

&lt;p&gt;You can find the SDK Tools download link over on the &lt;a href="http://www.sencha.com/products/sdk-tools/"&gt;Sencha Website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Ensure you download the SDK Tools 2 beta version, as it is compatible with Sencha Touch 2. Unfortunately it is only available for Mac at the time of writing this.&lt;/p&gt;

&lt;p&gt;Once installed, open up Terminal.app and confirm that the &lt;code&gt;sencha&lt;/code&gt; command is available (you will need to open a new Terminal window for it to work).&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/2b273w1G3q3V3w2V0k0L/Screen%20Shot%202011-12-09%20at%206.43.15%20PM.png" alt="sencha command in Terminal.app"&gt;&lt;/p&gt;

&lt;p&gt;If for some reason it is not available, open up your &lt;code&gt;~&amp;#47;.profile&lt;/code&gt; file (or your bash profile, if different) and check if the following lines are there:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;export PATH=&amp;#47;Applications&amp;#47;SenchaSDKTools-2.0.0-Developer-Preview:$PATH
export PATH=&amp;#47;Applications&amp;#47;SenchaSDKTools-2.0.0-Developer-Preview&amp;#47;command:$PATH
export PATH=&amp;#47;Applications&amp;#47;SenchaSDKTools-2.0.0-Developer-Preview&amp;#47;jsbuilder:$PATH
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If not, add them and save the file. Then open a new Terminal window and try again.&lt;/p&gt;

&lt;p&gt;If the &lt;code&gt;sencha&lt;/code&gt; command is still not available, please contact me at &lt;a href="mailto:rdougan@me.com"&gt;rdougan@me.com&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Your Application&lt;/h2&gt;

&lt;p&gt;By this point, I presume your application is fully functional, and is available on a web server. My local setup uses the Apache web server available on OSX by default. If you don&amp;#39;t know how to do this, Google is your friend.&lt;/p&gt;

&lt;p&gt;If you do not have an application but still want to follow along, you can download my sample application from &lt;a href="https://github.com/rdougan/cocktails-app"&gt;GitHub&lt;/a&gt;. Please follow the README to download and include Sencha Touch 2 into the project.&lt;/p&gt;

&lt;p&gt;Next, setup the example up so you can view it on a server. I can view the application at &lt;code&gt;http:&amp;#47;&amp;#47;rob.local&amp;#47;cocktails&amp;#47;&lt;/code&gt; (local URL), and it looks a little like this:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/1k1y2L0K04212J0Q3z0X/Screen%20Shot%202011-12-09%20at%206.02.16%20PM.png" alt="Sample application"&gt;&lt;/p&gt;

&lt;p&gt;The actual files on my Mac are available at &lt;code&gt;~&amp;#47;github&amp;#47;cocktails&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;Notes before we continue&lt;/h2&gt;

&lt;p&gt;Right now the SDK Tools builder is a little buggy. One of the main issues is that you &lt;em&gt;must&lt;/em&gt; require all Sencha Touch components you use.&lt;/p&gt;

&lt;p&gt;So let&amp;#39;s say you have a view called &lt;code&gt;MyApp.view.Detail&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class="javascript"&gt;Ext.define(&amp;#39;MyApp.view.Detail&amp;#39;, {
    extend: &amp;#39;Ext.Container&amp;#39;, 

    config: {
        items: [
            {
                xtype: &amp;#39;button&amp;#39;,
                text: &amp;#39;My Button&amp;#39;
            }
        ]
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Notice how we have one item in this view, which is a button. Now when you are running in development mode, Sencha Touch will know to load this file correctly, but in production mode, it will not. So you must add a requires statement into your view for any components you are using (third line):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Ext.define(&amp;#39;MyApp.view.Detail&amp;#39;, {
    extend: &amp;#39;Ext.Container&amp;#39;,
    requires: [&amp;#39;Ext.Button&amp;#39;],

    config: {
        items: [
            {
                xtype: &amp;#39;button&amp;#39;,
                text: &amp;#39;My Button&amp;#39;
            }
        ]
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You must do this for &lt;em&gt;all&lt;/em&gt; of your views, or when you build, it will not include those components for you.&lt;/p&gt;

&lt;p&gt;This will be fixed in a future release of the builder.&lt;/p&gt;

&lt;h2&gt;HTML Files&lt;/h2&gt;

&lt;p&gt;Your application probably already has a index.html file, but we must create one for both development and production.&lt;/p&gt;

&lt;h3&gt;index-debug.html - development&lt;/h3&gt;

&lt;p&gt;This index file is the one you should use for development. It will include uncompressed versions of Sencha Touch, and your application. It also uses dynamic loading, so loading time for your application will be much slower.&lt;/p&gt;

&lt;p&gt;Here is an example of my index-debug.html file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;!doctype html&amp;gt;
&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text&amp;#47;html; charset=utf-8&amp;quot;&amp;gt;
        &amp;lt;title&amp;gt;Cocktails&amp;lt;&amp;#47;title&amp;gt;

        &amp;lt;!-- Sencha Touch --&amp;gt;
        &amp;lt;script src=&amp;quot;lib&amp;#47;touch2&amp;#47;sencha-touch-debug.js&amp;quot;&amp;gt;&amp;lt;&amp;#47;script&amp;gt;

        &amp;lt;!-- Google Maps --&amp;gt;
        &amp;lt;script type=&amp;quot;text&amp;#47;javascript&amp;quot; src=&amp;quot;http:&amp;#47;&amp;#47;maps.google.com&amp;#47;maps&amp;#47;api&amp;#47;js?sensor=true&amp;quot;&amp;gt;&amp;lt;&amp;#47;script&amp;gt;

        &amp;lt;!-- CSS --&amp;gt;
        &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;resources&amp;#47;css&amp;#47;style.css&amp;quot;&amp;#47;&amp;gt;

        &amp;lt;!-- Application --&amp;gt;
        &amp;lt;script src=&amp;quot;app.js&amp;quot;&amp;gt;&amp;lt;&amp;#47;script&amp;gt;
    &amp;lt;&amp;#47;head&amp;gt;

    &amp;lt;body&amp;gt;&amp;lt;&amp;#47;body&amp;gt;
&amp;lt;&amp;#47;html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Two parts of this which are important:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Line 8&lt;/strong&gt; - you must include the &lt;code&gt;sencha-touch-debug.js&lt;/code&gt; file from the Sencha Touch SDK. You &lt;strong&gt;must&lt;/strong&gt; use this file.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Line 17&lt;/strong&gt; - the &lt;code&gt;app.js&lt;/code&gt; file is the base file of your application. All other application files will automatically get loaded.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;index.html - production&lt;/h3&gt;

&lt;p&gt;Here is an example of a index.html file. Your version should not vary much from this, other than the &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt; and perhaps including some extra resources.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;!doctype html&amp;gt;
&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text&amp;#47;html; charset=utf-8&amp;quot;&amp;gt;
        &amp;lt;title&amp;gt;Cocktails&amp;lt;&amp;#47;title&amp;gt;

        &amp;lt;!-- Google Maps --&amp;gt;
        &amp;lt;script type=&amp;quot;text&amp;#47;javascript&amp;quot; src=&amp;quot;http:&amp;#47;&amp;#47;maps.google.com&amp;#47;maps&amp;#47;api&amp;#47;js?sensor=true&amp;quot;&amp;gt;&amp;lt;&amp;#47;script&amp;gt;

        &amp;lt;!-- CSS --&amp;gt;
        &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;resources&amp;#47;css&amp;#47;style.css&amp;quot;&amp;#47;&amp;gt;

        &amp;lt;!-- Application --&amp;gt;
        &amp;lt;script src=&amp;quot;app-all.js&amp;quot;&amp;gt;&amp;lt;&amp;#47;script&amp;gt;
    &amp;lt;&amp;#47;head&amp;gt;

    &amp;lt;body&amp;gt;&amp;lt;&amp;#47;body&amp;gt;
&amp;lt;&amp;#47;html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;There is one very important part of this which &lt;em&gt;must&lt;/em&gt; be correct:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Line 14&lt;/strong&gt; - the &lt;code&gt;app-all.js&lt;/code&gt; file, which will be the compressed version of Sencha Touch &lt;strong&gt;and&lt;/strong&gt; your application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Creating your JSB3 file&lt;/h2&gt;

&lt;p&gt;The first thing you need to do is generate a &lt;strong&gt;jsb3&lt;/strong&gt; file. This file will contain a URL to every file your application uses, both custom and Sencha Touch source files. The SDK Tools builder will use this to then compile your application into 1 file.&lt;/p&gt;

&lt;p&gt;To generate your jsb3 file, run the following command from Terminal.app:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sencha create jsb -a http:&amp;#47;&amp;#47;rob.local&amp;#47;cocktails&amp;#47;index-debug.html -p app.jsb3
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As you can see, we just pass in a link to your &lt;code&gt;index-debug.html&lt;/code&gt; file (which must be on a server) and the path where we want to output the jsb3 file.&lt;/p&gt;

&lt;p&gt;You should now have a &lt;code&gt;app.jsb3&lt;/code&gt; that looks a little like this:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/3K1v063I16043y0I3T20/Screen%20Shot%202011-12-08%20at%203.13.59%20PM.png" alt="app.jsb3 file"&gt;&lt;/p&gt;

&lt;h2&gt;Updating the JSB3 file&lt;/h2&gt;

&lt;p&gt;There are a few bits we need to adjust to finish off the JSB3 configuration:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Update the &lt;code&gt;projectName&lt;/code&gt; and &lt;code&gt;licenseText&lt;/code&gt; properties right at the top of the file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scroll down to the bottom of the file, to where you see &lt;code&gt;Application - Production&lt;/code&gt;. What we want to do is include &lt;code&gt;sencha-touch-debug.js&lt;/code&gt; so all JavaScript your application needs is compressed into one file. You need to add an object into the &lt;code&gt;files&lt;/code&gt; array, and it &lt;em&gt;must&lt;/em&gt; be the first file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is an example of #2:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;{
    &amp;quot;name&amp;quot;: &amp;quot;Application - Production&amp;quot;,
    &amp;quot;target&amp;quot;: &amp;quot;app-all.js&amp;quot;,
    &amp;quot;compress&amp;quot;: true,
    &amp;quot;files&amp;quot;: [
        {
            &amp;quot;path&amp;quot;: &amp;quot;lib&amp;#47;touch2&amp;#47;&amp;quot;,
            &amp;quot;name&amp;quot;: &amp;quot;sencha-touch-debug.js&amp;quot;
        },
        {
            &amp;quot;path&amp;quot;: &amp;quot;&amp;quot;,
            &amp;quot;name&amp;quot;: &amp;quot;all-classes.js&amp;quot;
        },
        {
            &amp;quot;path&amp;quot;: &amp;quot;&amp;quot;,
            &amp;quot;name&amp;quot;: &amp;quot;app.js&amp;quot;
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Building the compressed application files&lt;/h2&gt;

&lt;p&gt;Finally, we are ready to roll. Open up Terminal.app again and run the follow command.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sencha build  -p app.jsb3 -d .
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Once the command has completed, you will have a new &lt;code&gt;app-all.js&lt;/code&gt; file. If you open up index.html in a browser, your application should load, but only with just one request for JavaScript.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/robertdougan/blog/~4/IS-jCTvVo4s" height="1" width="1"/&gt;</content>
    <updated>2012-01-06T20:47:28Z</updated>
    <published>2012-01-06T20:47:28Z</published>
  <feedburner:origLink>http://robertdougan.com/posts/packaging-your-sencha-touch-2-application-using-the-sencha-sdk-tools</feedburner:origLink></entry>
</feed>

