SlideShare ist ein Scribd-Unternehmen logo
1 von 51
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

N:1 Replication meets MHA
N:1 Replication meets MHAN:1 Replication meets MHA
N:1 Replication meets MHA
do_aki
 

Was ist angesagt? (6)

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

Ähnlich wie Stop Ember Time

Backbone intro
Backbone introBackbone intro
Backbone intro
Ian Yang
 
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxcase3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
tidwellveronique
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Paulo Ragonha
 

Ähnlich wie Stop Ember Time (20)

An introduction to Ember.js
An introduction to Ember.jsAn introduction to Ember.js
An introduction to Ember.js
 
Backbone intro
Backbone introBackbone intro
Backbone intro
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJS
 
Backbone
BackboneBackbone
Backbone
 
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxcase3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
 
Securing Client Side Data
 Securing Client Side Data Securing Client Side Data
Securing Client Side Data
 
Intro tobackbone
Intro tobackboneIntro tobackbone
Intro tobackbone
 
Backbone
BackboneBackbone
Backbone
 
spring3.2 java config Servler3
spring3.2 java config Servler3spring3.2 java config Servler3
spring3.2 java config Servler3
 
AngularJS Tips&Tricks
AngularJS Tips&TricksAngularJS Tips&Tricks
AngularJS Tips&Tricks
 
Customizer-ing Theme Options: A Visual Playground
Customizer-ing Theme Options: A Visual PlaygroundCustomizer-ing Theme Options: A Visual Playground
Customizer-ing Theme Options: A Visual Playground
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
Simpan data- ke- database
Simpan data- ke- databaseSimpan data- ke- database
Simpan data- ke- database
 
Puppet and AWS: Getting the best of both worlds
Puppet and AWS: Getting the best of both worldsPuppet and AWS: Getting the best of both worlds
Puppet and AWS: Getting the best of both worlds
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On Rails
 
F[4]
F[4]F[4]
F[4]
 
Building Your First Big Data Application on AWS
Building Your First Big Data Application on AWSBuilding Your First Big Data Application on AWS
Building Your First Big Data Application on AWS
 
Building Your First Big Data Application on AWS
Building Your First Big Data Application on AWSBuilding Your First Big Data Application on AWS
Building Your First Big Data Application on AWS
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.js
 
Drupal 7 Queues
Drupal 7 QueuesDrupal 7 Queues
Drupal 7 Queues
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Stop Ember Time