SlideShare a Scribd company logo
Basics for Ember.js
An introduction and some history
Stuck? Here are some resources…
•

https://developer.mozilla.org/en-US/

•

http://underscorejs.org

•

http://pivotal.github.io/jasmine/

•

http://www.2ality.com/2013/06/basic-javascript.html

•

http://www.2ality.com/2013/07/meta-style-guide.html
Getting better…
•

http://exercism.io/

•

Read Code:
•

https://github.com/jashkenas/underscore/blob/master/
underscore.js

•

https://github.com/jashkenas/backbone/blob/master/
backbone.js

•

https://github.com/emberjs/ember.js/tree/master/
packages
Some small things first
function.bind
function foo(bar) {
console.log(bar)
return bar
}
!

var f = foo.bind(null, "hello world")
console.log(typeof f) // function
f() // outputs hello world
Passing functions around
function Ork() {
this.description = "I am an Ork"
}
!

Ork.prototype.describe = function() {
console.log(this.description)
}
!

var ork = new Ork()
ork.describe() // I am an Ork
!

setTimeout(ork.describe, 100) // undefined
setTimeout(ork.describe.bind(ork), 100) // I am an Ork
MVC != MVC
Server-side MVC is not the only way!
Rails MVC
Observers
Embers MVC relies on Observers
Observers are a central part to MVC here
So what is the observer pattern?
http://addyosmani.com/resources/essentialjsdesignpatterns/
book/
“The observer pattern is a software design pattern in
which an object, called the subject, maintains a list of
its dependents, called observers, and notifies them
automatically of any state changes, usually by calling
one of their methods.” — Wikipedia
Observable
functions Ork(name) {
this.name = name
this._observers = []
}
!

Ork.prototype.smash = function(thing) {
this._observers.forEach(function(o) {
o.notify(this, "smashed " + thing);
}, this)
}
!

Ork.prototype.registerObserver = function(observer) {
this._observers.push(observer)
}
Observer
function OrkMaster(name) {
this.name = name
}
!

OrkMaster.prototype.notify = function(ork, message) {
console.log(this.name + " here " +
ork.name + " told me he "
+ message)
}
!

OrkMaster.prototype.observe = function(ork) {
ork.registerObserver(this)
}
Putting it all together

var master = new OrkMaster("Uruk-hai")
var gobgrub = new Ork("Gobgrub")
var nazsnaga = new Ork("Nazsnaga")
!

master.observe(gobgrub)
master.observe(nazsnaga)
!

gobgrub.smash("human")
nazsnaga.smash("drawf")
!

// Uruk-hai here Gobgrub told me he smashed human
// Uruk-hai here Nazsnaga told me he smashed drawf
http://jsfiddle.net/sideshowcoder/fRDDL/
JavaScript already offers this via events
Evented Observerable

function Ork(name) {
this.name = name
var _e = document.createElement("div")
this.dispatchEvent = _e.dispatchEvent.bind(_e)
this.addEventListener = _e.addEventListener.bind(_e)
}
!

Ork.prototype.smash = function(thing) {
var evData = { message: "smashed " + thing, ork: this }
var ev = new CustomEvent("orkevent", { detail: evData })
this.dispatchEvent(ev)
}
Evented Observer
function OrkMaster(name) {
this.name = name
}
!

OrkMaster.prototype.handleEvent = function(ev) {
var ork = ev.detail.ork
var message = ev.detail.message
console.log(this.name + " here " +
ork.name + " told me he "
+ message)
}
!

OrkMaster.prototype.observe = function(ork) {
var handler = this.handleEvent.bind(this)
ork.addEventListener("orkevent", handler)
}
http://jsfiddle.net/sideshowcoder/5cPAg/
Why do all this?
Decoupling
Automatic updates, or Data Binding
!

!

!

!
!
!

function Ork() {
this._observers = []
}
Ork.prototype.setName = function(name) {
this.name = name
this._observers.forEach(function(o) {
o.notify(this)
}, this)
}
Ork.prototype.addObserver = function(observer) {
this._observers.push(observer)
}
var nameObserver = {
notify: function(ork) {
document.getElementById("ork-name").innerHTML = ork.name
}
}
var ork = new Ork()
ork.addObserver(nameObserver)
ork.setName("Bar")
setTimeout(function() {
ork.setName("Gobgrub")
}, 1000)
http://jsfiddle.net/sideshowcoder/GLfbn/
http://jsfiddle.net/sideshowcoder/J2Cn6/
Only the model is the source for data
There is not “It’s over after the request is done”
The Run Loop
Ember.run
“…is a programming construct that waits for and
dispatches events or messages in a program”
!

Thanks Wikipedia!
https://machty.s3.amazonaws.com/ember-runloop-visual/index.html
Why in Ember?
Ember needs some boundaries!
Model layer is “THE TRUTH”™
Performance
MVCs all the way down
The Routes / Router are the “Grand Daddy”
Ember did not invent this
Ember ~ Sproutcore ~ Cocoa
If you want to understand Ember look at Cocoa
!
And listen to Yehuda Katz…
!
http://www.youtube.com/watch?v=s1dhXamEAKQ
!

More Related Content

What's hot (20)

PDF
Ansible leveraging 2.0
bcoca
 
KEY
[Coscup 2012] JavascriptMVC
Alive Kuo
 
PDF
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
Ryosuke IWANAGA
 
PDF
Puppet Camp 2012
Server Density
 
PPTX
Spine.js
wearefractal
 
KEY
Node.js 0.8 features
Nicholas McClay
 
PDF
MySQL in Go - Golang NE July 2015
Mark Hemmings
 
PDF
V2 and beyond
jimi-c
 
PDF
Hacking ansible
bcoca
 
PDF
ReactJS & Material-ui Hello world
Daniel Lim
 
PDF
Asynchronous programming patterns in Perl
deepfountainconsulting
 
PDF
More tips n tricks
bcoca
 
PDF
EC2
Igor Kapkov
 
PDF
A Gentle Introduction to Event Loops
deepfountainconsulting
 
PDF
What the web platform (and your app!) can learn from Node.js
wbinnssmith
 
PPTX
Intro to Ember.JS 2016
Sandino Núñez
 
KEY
Devsumi2012 攻めの運用の極意
Ryosuke IWANAGA
 
PDF
Ansible tips & tricks
bcoca
 
PDF
Build web application by express
Shawn Meng
 
PDF
AnsibleFest 2014 - Role Tips and Tricks
jimi-c
 
Ansible leveraging 2.0
bcoca
 
[Coscup 2012] JavascriptMVC
Alive Kuo
 
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
Ryosuke IWANAGA
 
Puppet Camp 2012
Server Density
 
Spine.js
wearefractal
 
Node.js 0.8 features
Nicholas McClay
 
MySQL in Go - Golang NE July 2015
Mark Hemmings
 
V2 and beyond
jimi-c
 
Hacking ansible
bcoca
 
ReactJS & Material-ui Hello world
Daniel Lim
 
Asynchronous programming patterns in Perl
deepfountainconsulting
 
More tips n tricks
bcoca
 
A Gentle Introduction to Event Loops
deepfountainconsulting
 
What the web platform (and your app!) can learn from Node.js
wbinnssmith
 
Intro to Ember.JS 2016
Sandino Núñez
 
Devsumi2012 攻めの運用の極意
Ryosuke IWANAGA
 
Ansible tips & tricks
bcoca
 
Build web application by express
Shawn Meng
 
AnsibleFest 2014 - Role Tips and Tricks
jimi-c
 

Viewers also liked (7)

PPTX
Untold benefits of travelling
Trawel Mart
 
PPTX
8 Benefits of Travelling
traveloffcourse
 
PDF
The Benefits of Travelling.
Umar Akif
 
PDF
Farming Unicorns: Building Startup & Investor Ecosystems
Dave McClure
 
PDF
How to Use Social Media to Influence the World
Sean Si
 
PPTX
Shall we play a game?
Maciej Lasyk
 
PDF
UX, ethnography and possibilities: for Libraries, Museums and Archives
Ned Potter
 
Untold benefits of travelling
Trawel Mart
 
8 Benefits of Travelling
traveloffcourse
 
The Benefits of Travelling.
Umar Akif
 
Farming Unicorns: Building Startup & Investor Ecosystems
Dave McClure
 
How to Use Social Media to Influence the World
Sean Si
 
Shall we play a game?
Maciej Lasyk
 
UX, ethnography and possibilities: for Libraries, Museums and Archives
Ned Potter
 
Ad

Similar to Ember background basics (20)

KEY
JavaScript Growing Up
David Padbury
 
PDF
The Beauty of Java Script
Michael Girouard
 
PDF
The Beauty Of Java Script V5a
rajivmordani
 
KEY
Express Presentation
aaronheckmann
 
PDF
dojo.Patterns
Peter Higgins
 
PDF
ES6: The Awesome Parts
Domenic Denicola
 
KEY
Your Library Sucks, and why you should use it.
Peter Higgins
 
PDF
All I Need to Know I Learned by Writing My Own Web Framework
Ben Scofield
 
PPTX
Nantes Jug - Java 7
Sébastien Prunier
 
PDF
Secrets of JavaScript Libraries
jeresig
 
PDF
Great Developers Steal
Ben Scofield
 
PPTX
JavaScript performance patterns
Stoyan Stefanov
 
PDF
Future of Web Apps: Google Gears
dion
 
PDF
Cross Domain Web
Mashups with JQuery and Google App Engine
Andy McKay
 
PDF
A Little Backbone For Your App
Luca Mearelli
 
PDF
Matthew Eernisse, NodeJs, .toster {webdev}
.toster
 
PDF
Trimming The Cruft
Peter Higgins
 
KEY
前端概述
Ethan Zhang
 
PDF
GoCracow #5 Bartlomiej klimczak - GoBDD
Bartłomiej Kiełbasa
 
KEY
Txjs
Peter Higgins
 
JavaScript Growing Up
David Padbury
 
The Beauty of Java Script
Michael Girouard
 
The Beauty Of Java Script V5a
rajivmordani
 
Express Presentation
aaronheckmann
 
dojo.Patterns
Peter Higgins
 
ES6: The Awesome Parts
Domenic Denicola
 
Your Library Sucks, and why you should use it.
Peter Higgins
 
All I Need to Know I Learned by Writing My Own Web Framework
Ben Scofield
 
Nantes Jug - Java 7
Sébastien Prunier
 
Secrets of JavaScript Libraries
jeresig
 
Great Developers Steal
Ben Scofield
 
JavaScript performance patterns
Stoyan Stefanov
 
Future of Web Apps: Google Gears
dion
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Andy McKay
 
A Little Backbone For Your App
Luca Mearelli
 
Matthew Eernisse, NodeJs, .toster {webdev}
.toster
 
Trimming The Cruft
Peter Higgins
 
前端概述
Ethan Zhang
 
GoCracow #5 Bartlomiej klimczak - GoBDD
Bartłomiej Kiełbasa
 
Ad

More from Philipp Fehre (19)

PPTX
node.js and native code extensions by example
Philipp Fehre
 
PDF
Jruby a Pi and a database
Philipp Fehre
 
PDF
Couchbase Mobile on Android
Philipp Fehre
 
PDF
From 0 to syncing
Philipp Fehre
 
PDF
Node.js and couchbase Full Stack JSON - Munich NoSQL
Philipp Fehre
 
PDF
You got schema in my json
Philipp Fehre
 
PDF
What is new in Riak 2.0
Philipp Fehre
 
PDF
Ember learn from Riak Control
Philipp Fehre
 
PDF
Testing tdd jasmine
Philipp Fehre
 
PDF
Testing tdd dom
Philipp Fehre
 
PDF
Something about node basics
Philipp Fehre
 
PDF
A little more advanced node
Philipp Fehre
 
PDF
Something about node in the realworld
Philipp Fehre
 
PDF
Riak Intro at Munich Node.js
Philipp Fehre
 
PDF
PUT Knowledge BUCKET Brain KEY Riak
Philipp Fehre
 
PDF
Campfire bot lightning talk
Philipp Fehre
 
PDF
Lighting fast rails with zeus
Philipp Fehre
 
PDF
JavaScript frontend testing from failure to good to great
Philipp Fehre
 
KEY
Network with node
Philipp Fehre
 
node.js and native code extensions by example
Philipp Fehre
 
Jruby a Pi and a database
Philipp Fehre
 
Couchbase Mobile on Android
Philipp Fehre
 
From 0 to syncing
Philipp Fehre
 
Node.js and couchbase Full Stack JSON - Munich NoSQL
Philipp Fehre
 
You got schema in my json
Philipp Fehre
 
What is new in Riak 2.0
Philipp Fehre
 
Ember learn from Riak Control
Philipp Fehre
 
Testing tdd jasmine
Philipp Fehre
 
Testing tdd dom
Philipp Fehre
 
Something about node basics
Philipp Fehre
 
A little more advanced node
Philipp Fehre
 
Something about node in the realworld
Philipp Fehre
 
Riak Intro at Munich Node.js
Philipp Fehre
 
PUT Knowledge BUCKET Brain KEY Riak
Philipp Fehre
 
Campfire bot lightning talk
Philipp Fehre
 
Lighting fast rails with zeus
Philipp Fehre
 
JavaScript frontend testing from failure to good to great
Philipp Fehre
 
Network with node
Philipp Fehre
 

Recently uploaded (20)

PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 

Ember background basics