SproutCore - A Next Gen JavaScript Framework

27
SproutCore a next generation javascript framework

description

Introduction to the core concepts of SproutCore, a framework for building desktop-like web applications.

Transcript of SproutCore - A Next Gen JavaScript Framework

Page 1: SproutCore - A Next Gen JavaScript Framework

SproutCorea next generation javascript framework

Page 2: SproutCore - A Next Gen JavaScript Framework

What

Desktop-like Apps

Client Side MVC

Inspired by Cocoa

Page 3: SproutCore - A Next Gen JavaScript Framework

Why

Common App Features for Free

Cross-browser Optimized

Glue-code Eliminated

Page 4: SproutCore - A Next Gen JavaScript Framework

JavaScript and ProudNot trying to be Java, Ruby, Python, Obj-C

Page 5: SproutCore - A Next Gen JavaScript Framework

Features

Page 6: SproutCore - A Next Gen JavaScript Framework

At the code level...

Page 7: SproutCore - A Next Gen JavaScript Framework

Properties

Example: A contact’s first name

Most are simple values - numbers, strings, objects

Can be functions which dynamically “compute” value

Page 8: SproutCore - A Next Gen JavaScript Framework

Observers

Watch for property changes

Takes some action

Examples: Update view, send data to server

Page 9: SproutCore - A Next Gen JavaScript Framework

Bindings

Two objects, “bound” together

When one changes, the other changes also

Page 10: SproutCore - A Next Gen JavaScript Framework

Example

The contact firstName property is bound to the textFieldView value property.

When the contact’s firstName is updated, textFieldView’s value is updated automatically.

When textFieldView’s value changes, the valueDidChange observer kicks in & updates the UI.

Page 11: SproutCore - A Next Gen JavaScript Framework

Glue Code Eliminated!Controllers and views automatically stay in sync

with the model objects in your application!

Page 12: SproutCore - A Next Gen JavaScript Framework

But...there’s a small price to pay

Page 13: SproutCore - A Next Gen JavaScript Framework

Key Value Coding

Access properties with object.get(key)

Set properties with object.set(key, value);

This allows SproutCore to watch things change

Abbreviated as “KVC”

Page 14: SproutCore - A Next Gen JavaScript Framework

Example

Page 15: SproutCore - A Next Gen JavaScript Framework

Computed Properties

Accessed like stored properties ( with get() )

Calls a function to compute the value

Declared with .property()

Page 16: SproutCore - A Next Gen JavaScript Framework

Key Value Observing

Allows Object A to observe changes to Object B

How binding is able to work

Abbreviated as KVO

Automatic for stored (non-computed) properties

Requires a little setup for computed properties...

Page 17: SproutCore - A Next Gen JavaScript Framework

Computed Property KVO

When declaring, list the attributes the computed property relies on:

Page 18: SproutCore - A Next Gen JavaScript Framework

User Interface Features

Page 19: SproutCore - A Next Gen JavaScript Framework

ControlsSC.ListView SC.GridView

Page 20: SproutCore - A Next Gen JavaScript Framework

ControlsSC.SourceListView Form Controls

Page 21: SproutCore - A Next Gen JavaScript Framework

Controls

Split-Panes

Dialogs, Pop-up Menus, Pickers

Native-Controls

Page 22: SproutCore - A Next Gen JavaScript Framework

Developer Tools

Page 23: SproutCore - A Next Gen JavaScript Framework

Generators

Generate skeletons for your application, models, views, controllers

Helps you get started quickly

Gives you a standard place to put things

Page 24: SproutCore - A Next Gen JavaScript Framework

Helpers

Generate your views with small, declarative helpers

Similar to Ruby on Rails view helpers

In fact, written in Ruby!

Page 25: SproutCore - A Next Gen JavaScript Framework

Development Server

Handles including JS files and view partials into your HTML file - less work for you.

Allows change-and-refresh style development

Can proxy to external website backends for server interaction.

Page 26: SproutCore - A Next Gen JavaScript Framework

Build Tools

Packages all assets into single files - 1 HTML, 1 CSS, 1 JavaScript.

Minifies your JavaScript

Host your app on any server or CDN - just static files

Page 27: SproutCore - A Next Gen JavaScript Framework

ThanksScott Becker

http://synthesis.sbecker.net