• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Runtime-Introduction

This version was saved 14 years, 6 months ago View current version     Page history
Saved by Charles Jolley
on October 20, 2009 at 2:37:31 pm
 

The SproutCore Runtime framework provides the basic tools you need to write large-scale applications in JavaScript.  This framework will form the fabric of your application.  You will use it to define your classes, connect them together, to benchmark and test your results as well. 

 

In addition, Runtime is can be used as a free-standing library.  You can down a built version of it and use it to create dynamic web pages when you don't want to use the full blow SproutCore application stack.

 

This programming guide will tell you everything you need to know about using the Runtime framework in your application including how to create objects, setup bindings, add observers, defer execution of code, work with sets, index sets and more.

 

Who Should Read This Guide

 

You should read this guide first if you are planning to work with any of the other frameworks in the SproutCore application stack.  This includes building desktop apps, mobile apps, or using SproutCore mini on regular web pages.

 

Outline

 

  1. Overview

 

  1. Property Observing provides a way for you to keep all of the pieces of your application in sync without writing glue code.  
    1. Using property observing means you can spend more time working on features while eliminating one of the most common sources of bugs in an application.
    2. Example: user presses a button to add a new item
      1. call a new method to update a record
      2. call a method to update the list of records
      3. call a method to update the count of records
      4. call a method to display the details of the new record
      5. etc, etc.
      6. With property observing, just create the new record.  All the objects observing the list of records through bindings and observers will update automatically.
  2. Property observing includes a number of related tools you can use to propagate changes. You should learn what each of these are and when to use them in your application is get the best performance.
    1. Observers - functions that "observe" a property.  Whenever the property value changes, the observer function will be executed.  You should mostly use observers to notice when properties change on your own object.
    2. Bindings - bindings tie properties of one object to another object, so that whenever the value changes in one property, the other property will be changed also.  This is how you tie together the big pieces of your application.  
    3. Computed Properties - These are properties that are actually functions which run.  You often use computed properties to create prepared "intermediate" values from your input values on an object.  In the process, you will automatically cache those results, keeping your application fast.
  3. Notification Timing
    1. Observers are notified immediately
    2. Bindings are triggered only at the end of the run loop
    3. Computed properties are 'invalidated' whenever their dependent keys changed.  This means the next time you get the property value, it will be recomputed.  If no one tries to get the value again, there will be not cost.
  4. How SproutCore Property Observing Compares To Other Frameworks
    1. Cocoa bindings for example are far less flexible and require a lot more configuration.  They do not map well to JavaScript because they require so much manual setup.

 

Comments (0)

You don't have permission to comment on this page.