Stop! Ember Time!
Wednesday, 9 October 13
Carl Woodward
Wednesday, 9 October 13
@cjwoodward
Wednesday, 9 October 13
Wednesday, 9 October 13
Wednesday, 9 October 13
Why Ember?
Wednesday, 9 October 13
Wednesday, 9 October 13
Well structured
Wednesday, 9 October 13
Data bound
Wednesday, 9 October 13
Fast
Wednesday, 9 October 13
Javascript MVC
framework
Wednesday, 9 October 13
Wednesday, 9 October 13
Route
Model
ControllerView
Template
User
Wednesday, 9 October 13
Route
Router
Find a model
Before model
Wednesday, 9 October 13
WeightsProgram.ExerciseRoute	
  =	
  Ember.Route.extend
	
  	
  model:	
  (params)	
  -­‐>
	
  	
  	
  	
  WeightsProgram.Exercise.find	
  params["exercise_id"]
* Using Ember Model
Wednesday, 9 October 13
Controller
Route
Actions from UI
Wednesday, 9 October 13
WeightsProgram.AuthenticatedExerciseController	
  =	
  
Ember.ObjectController.extend
	
  	
  actions:
	
  	
  	
  	
  saveReps:	
  -­‐>
	
  	
  	
  	
  	
  	
  @get("content").set("current_max",	
  
@get("content").get("new_max"))
	
  	
  	
  	
  	
  	
  @get("content").save()
	
  	
  	
  	
  	
  	
  @transitionToRoute("authenticated.week",	
  
@get("content.week"))
* Using Ember Model
Wednesday, 9 October 13
View
Controller
Element events
didInsertElement
Wednesday, 9 October 13
WeightsProgram.AuthenticatedWeekView	
  =	
  
Ember.View.extend()
Wednesday, 9 October 13
Template
View
{{#link-to “week” week}}Week Link{{/link-to}}
<form {{action "saveReps" on="submit"}}>
<h3>{{movement.name}}</h3>
Wednesday, 9 October 13
Templating
Wednesday, 9 October 13
Handlebars
or
Emblem
Wednesday, 9 October 13
if	
  isEditing
	
  	
  form.post-­‐form	
  role="form"	
  submit="create"
	
  	
  	
  	
  .form-­‐group
	
  	
  	
  	
  	
  	
  button.btn.btn-­‐primary	
  click="stopEditing"	
  View
Emblem
Wednesday, 9 October 13
<h2>Week	
  {{number}}</h2>
<div	
  class="menu">
	
  	
  {{#each	
  exercise	
  in	
  exercises}}
	
  	
  	
  	
  <h3>
	
  	
  	
  	
  	
  	
  {{#link-­‐to	
  "authenticated.exercise"	
  exercise}}
	
  	
  	
  	
  	
  	
  	
  	
  {{exercise.movement.name}}
	
  	
  	
  	
  	
  	
  {{/link-­‐to}}
	
  	
  	
  	
  </h3>
	
  	
  {{/each}}
</div>
Handlebars
Wednesday, 9 October 13
Application layout
Wednesday, 9 October 13
<div	
  class="container	
  work">
	
  	
  <div	
  class="row">
	
  	
  	
  	
  <div	
  class="col-­‐sm-­‐12">
	
  	
  	
  	
  	
  	
  <h1>Strength	
  Program</h1>
	
  	
  	
  	
  </div>
	
  	
  </div>
	
  	
  <div	
  class="row">
	
  	
  	
  	
  <div	
  class="col-­‐sm-­‐12">
	
  	
  	
  	
  	
  	
  {{	
  outlet	
  }}
	
  	
  	
  	
  </div>
	
  	
  </div>
</div>
Handlebars
Wednesday, 9 October 13
outlet is like yield in
rails views
{{outlet}}
Wednesday, 9 October 13
Persistence
Wednesday, 9 October 13
Ember Data
or
Ember Model
Wednesday, 9 October 13
Ember Model =
customisable
Wednesday, 9 October 13
Wednesday, 9 October 13
WeightsProgram.Exercise	
  =	
  Ember.Model.extend
	
  	
  id:	
  Ember.attr()
	
  	
  reps:	
  Ember.attr()
	
  	
  initial_max_value:	
  Ember.attr()
	
  	
  movement:	
  Ember.belongsTo("WeightsProgram.Movement",	
  
key:	
  "movement_id",	
  embedded:	
  false)
	
  	
  accessories:	
  
Ember.hasMany("WeightsProgram.Accessory",	
  key:	
  
"accessory_ids",	
  embedded:	
  false)
WeightsProgram.Exercise.url	
  =	
  "/exercises"
WeightsProgram.Exercise.adapter	
  =	
  
Ember.RESTAdapter.create()
WeightsProgram.Exercise.rootKey	
  =	
  "exercise"
WeightsProgram.Exercise.collectionKey	
  =	
  "exercises"
Ember Model
Wednesday, 9 October 13
EmberBlog.Post	
  =	
  DS.Model.extend
	
  	
  title:	
  DS.attr("string")
	
  	
  publishedOn:	
  DS.attr("string")
	
  	
  body:	
  DS.attr("string")
Ember Data
Wednesday, 9 October 13
JJ Abrams
Wednesday, 9 October 13
Tips
Wednesday, 9 October 13
Don’t try and preload
associations
Wednesday, 9 October 13
didInsertView
Wednesday, 9 October 13
model.on(“didCreateRecord”)
Wednesday, 9 October 13
WeightsProgram.AuthenticatedProgramController	
  =	
  
Ember.ObjectController.extend
	
  	
  actions:
	
  	
  	
  	
  createWeek:	
  -­‐>
	
  	
  	
  	
  	
  	
  number	
  =	
  @get("weeks.lastObject.number")	
  +	
  1
	
  	
  	
  	
  	
  	
  week	
  =	
  WeightsProgram.Week.create	
  program_id:	
  
@get("id"),	
  number:	
  number
	
  	
  	
  	
  	
  	
  week.on	
  "didCreateRecord",	
  =>
	
  	
  	
  	
  	
  	
  	
  	
  @get("model").reload()
	
  	
  	
  	
  	
  	
  	
  	
  @transitionToRoute("authenticated.program",	
  
@get("model"))
	
  	
  	
  	
  	
  	
  week.save()
Ember Model
Wednesday, 9 October 13
Computed Properties
Wednesday, 9 October 13
Wednesday, 9 October 13
increase_percentage:	
  (-­‐>
	
  	
  @get("current_max")	
  /	
  @get("previous_max"))	
  -­‐	
  1
).property("current_max",	
  "previous_max")
Wednesday, 9 October 13
Include any attribute you
need to create the model.
E.g. program_id
Wednesday, 9 October 13
Nested routes require nested
names
Wednesday, 9 October 13
WeightsProgram.AuthenticatedProgramController
WeightsProgram.Router.map	
  -­‐>
	
  	
  @resource	
  "authenticated",	
  path:	
  "/",	
  -­‐>
	
  	
  	
  	
  @route	
  "program",	
  path:	
  "/programs/:program_id"
WeightsProgram.AuthenticatedProgramView
app/assets/javascripts/views/authenticated/program.hbs
Wednesday, 9 October 13
Only use nested resources
with nested outlets
Wednesday, 9 October 13
Wednesday, 9 October 13
ember-rails works really
well
Wednesday, 9 October 13
jsbin
Wednesday, 9 October 13
discuss.emberjs.com
Read	
  discourse	
  source	
  code
#emberjs-­‐dev
Wednesday, 9 October 13
Demo
Wednesday, 9 October 13

More Related Content

PDF
Go-Couchbase Golang Paris 2015/12/17
PPTX
3rd meetup - Intro to Amazon EMR
PDF
Optimizing Laravel for Production
PDF
"Service Worker: Let Your Web App Feel Like a Native "
PPTX
Introduction to WordPress Development - Hooks
PPT
Introducing to node.js
PDF
NodeJS @ ACS
PDF
Build your website with awestruct and publish it on the cloud with git
Go-Couchbase Golang Paris 2015/12/17
3rd meetup - Intro to Amazon EMR
Optimizing Laravel for Production
"Service Worker: Let Your Web App Feel Like a Native "
Introduction to WordPress Development - Hooks
Introducing to node.js
NodeJS @ ACS
Build your website with awestruct and publish it on the cloud with git

What's hot (6)

PDF
Future Decoded - Node.js per sviluppatori .NET
PDF
倒计时优化点滴
PPTX
Baking in the cloud with packer and puppet
PDF
s3_website
PPTX
N:1 Replication meets MHA
PDF
Backbonejs on Rails
Future Decoded - Node.js per sviluppatori .NET
倒计时优化点滴
Baking in the cloud with packer and puppet
s3_website
N:1 Replication meets MHA
Backbonejs on Rails
Ad

Similar to Stop Ember Time (9)

PDF
Intro to Ember.js
PDF
An introduction to Ember.js
PDF
EmberJS
PPTX
Intro to Ember.JS 2016
PDF
Avoiding Common Pitfalls in Ember.js
PDF
Architecture: ember.js and AngularJS
PDF
Building Ambitious Web Apps with Ember
PDF
Create an application with ember
PPTX
Introduction to Ember.js
Intro to Ember.js
An introduction to Ember.js
EmberJS
Intro to Ember.JS 2016
Avoiding Common Pitfalls in Ember.js
Architecture: ember.js and AngularJS
Building Ambitious Web Apps with Ember
Create an application with ember
Introduction to Ember.js
Ad

Recently uploaded (20)

PPTX
Chapter 5: Probability Theory and Statistics
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Flame analysis and combustion estimation using large language and vision assi...
PPTX
The various Industrial Revolutions .pptx
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Developing a website for English-speaking practice to English as a foreign la...
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
UiPath Agentic Automation session 1: RPA to Agents
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PDF
STKI Israel Market Study 2025 version august
PPTX
Modernising the Digital Integration Hub
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PPTX
Configure Apache Mutual Authentication
PDF
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
Enhancing emotion recognition model for a student engagement use case through...
Chapter 5: Probability Theory and Statistics
NewMind AI Weekly Chronicles – August ’25 Week III
Flame analysis and combustion estimation using large language and vision assi...
The various Industrial Revolutions .pptx
A contest of sentiment analysis: k-nearest neighbor versus neural network
Developing a website for English-speaking practice to English as a foreign la...
Benefits of Physical activity for teenagers.pptx
Taming the Chaos: How to Turn Unstructured Data into Decisions
UiPath Agentic Automation session 1: RPA to Agents
Module 1.ppt Iot fundamentals and Architecture
Getting started with AI Agents and Multi-Agent Systems
Credit Without Borders: AI and Financial Inclusion in Bangladesh
STKI Israel Market Study 2025 version august
Modernising the Digital Integration Hub
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Configure Apache Mutual Authentication
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Enhancing emotion recognition model for a student engagement use case through...

Stop Ember Time