Building Sproutcore Apps with Statecharts (part 1)

by Evin

State Types

Introduction

In this post, we will discuss creating a sproutcore application using a modeling method called ‘Statecharts’. This was invented by a man named David Harel, who invented it in order to have a state diagram that could model things like: superstates; concurrent states; and activities as part of a state. These are starting to gain more use in the software development world because of the distinct advantages that it provides to developers. These advantages include, but are not limited to:

Read the rest of this entry »

Monkeypatching Sproutcore with Mixins

by Evin

Have you ever needed a function specific to your application, but you want it to work like the rest of Sproutcore? You can use the power of mixins to monkey patch Sproutcore in your application. I needed a call on SC.Record like resourceUrl() but I needed something like pluralResourceUrl() because the RESTful API on the back end had a different url for lists of objects that asking for a single object…

Read the rest of this entry »

Multiline strings

by Evin

Javascript is a very strange and often misunderstood language. One of the byproducts of the many different implementations are the many undocumented features. Among these is the very convenient, especially for fixture data, multi-line string. Here’s how you do it:

  var s= "\
          some text \
          some more lines\
          want line breaks? \n\
          javascript is cool\
  ";

Basically the last character of every line must be a \.

Sproutcore in TextMate

by Evin

I love developing with TextMate. I discovered it my Sr. year of college when I saw it in a now infamous video. Since then I’ve used it for all my coding projects and frankly other ide’s give me the jibblies. So today I’ll be showing how I’ve set up my environment with the Sproutcore TextMate bundle.

Read the rest of this entry »

Distributed Development with Git and the Single Integrator (Part 2)

by Evin

In the last post, I discussed the actions of the developers on the project. In this post, I will talk about the other half of the story. After one of the developers finishes their task or topic branch and they email the integrator (me), I check my emails usually at the end of the day and start my integration process. The single integrator process is great because it provides a forced code review gate that slows the commits to the master branch and forces a level of quality control and provides a natural time for this. It works great with geographically dispersed teams and helps everyone be highly effective with their time coding and reviewing while maintaining the best flexibility.

Read the rest of this entry »

Distributed Development with Git and the Single Integrator (Part 1)

by Evin

On our recent project that Mike and I are working on, we are using Git and a highly defined process for development that is centered around a single integrator (me) and a team of developers that are geographically dispersed on a very complex application. We also have the trouble that the deployment server runs off of a code base that is stored in Subversion. We had to write a simple script that slaves a subversion repository to the changes that we make in Git. This is almost finished and we hope to tie it directly to pushes on the Git master branch.

Read the rest of this entry »

Key Value Coding and Key Value Observing (KVC & KVO)

by Evin

We will look at some structure to using Sproutcore’s Key Value Coding (KVC) and Key Value Observing (KVO) framework. KVC and KVO is a direct port from the Cocoa framework, but it is better in Sproutcore because it is a foundational construct rather than an addition as it is in the Cocoa Framework. This is where most of the power of Sproutcore can be seen and there is a good paradigm that should be used to harness most of this power. We will start with a short discussion on what KVC and KVO is:

Read the rest of this entry »

Sproutcore Delegates

by Evin

Recently I needed to trigger an action when a selection was made on a list view.  Writing my own list view would have been to much work so I figured I’d look for a delegate. I started by looking at SC.ListView and found that it extended SC.CollectionView which has SC.CollectionViewDelegate as a mixin. CollectionViewDelegate has lots of methods and the one I want is collectionViewShouldSelectItem which, according to the docs is called, “by the collection when attempting to select an item.”
So, I added a collectionViewShouldSelectItem method to my core object:

App = SC.Object.create({
 
collectionViewShouldSelectItem: function (view, item) {
    //execute my action here
    return YES;  //return the default true...
  }
 
});

Then Set my core object as the delegate property in my rhtml:

<% scroll_view :scroll do %>
  <%= list_view :list_view,
           :class => 'list_view',
           :content_value_key => 'name',
           :delegate=>'App',
           :bind => {
                    :content => 'App.listController.arrangedObjects',
                    :selection => 'App.listController.selection'
                    } %>
 <% end %>

Done! Now my delegate fires when the list view selection is made.

First Post

by Evin

This used to be the stupid default post.  But I’m officially planting a flag on this little corner of the internet and declaring it mine!