SlideShare a Scribd company logo
Dev-day
                Ember.js
A JavaScript framework for creating ambitious web
                   applications


                 Juliana Lucena
                  26 Oct 2012
Why?




    • Clearly separate back-end and front-
      end
    • Faster user    app interaction
    • Makes your life easier :)



2
Ember.js




    • Browser based MVC framework
    • Eliminates boilerplate
    • Provides architecture
    • Based on event propagation



3
Dependencies




    • jQuery
    • Handlebars.js - Template language

      <script type="text/x-handlebars" data-template-name="answer">
        <a href="#" class="author-name">{{ answer.author.name }}</a>
        <span class="status-info">respondeu:</span>
        {{#if answer.created_at}}
          {{datetime answer.created_at}}
        {{/if}}
        <p class="input-user">{{ answer.content.text }}</p>
      </script>


4
Examples




    • http://emberjs.com/examples/
    • https://github.com/dgeb/
      ember_data_example




5
Ember.js MVC


6
MVC Workflow

                                         User
                       Notifies
    Model                               action
                                                          View


       Updates
                           Controller                   Updates



                 • Tracks the app’s state
    Router       • Affects the application’s view hierarchy
                 • Mediates between the MVC components
                            Serialize
                 URL                    Usable app state
                          Deserialize


7
Hello Redu

var App = Em.Application.create();

App.ApplicationView = Em.View.extend({
  templateName: 'application'
});

App.ApplicationController = Em.View.extend({!
});

App.Router = Em.Router.extend({                        index.html
  root: Ember.Route.extend({
                                           (...)
     index: Ember.Route.extend({
                                           <body>
        route: '/'                           <script type="text/x-handlebars"
     })                                    data-template-name="application">
  })                                           <h1>Hello Redu! (chuckle)</h1>
});                                          </script>
                                           </body>
                                           (...)
App.initialize();

                                                   http://jsfiddle.net/x8zpH/1/


8
M for Model
        Ember.Object




9
Ember.Object



     • Enhanced JavaScript object model
     • Computed Properties (synthetizes
       properties)
     • Observers (reacts to changes)
     • Bindings (syncs objects)
                                  Always access properties
                                     using get and set

10
Ember.Object

var App = Ember.Application.create();

App.Person = Em.Object.extend({
  firstName: null,
  lastName: null,

  fullName: function(){
      return this.get('firstName') + " " + this.get('lastName');
  }.property('firstName', 'lastName')
});                                     Computed Property

var john = App.Person.create({
  firstName: "John",
  lastName: "Doe"
});
john.get("fullName"); // John Doe
                                           What about computed property for arrays, hãn?

                                    femalesCount: function() {
http://jsfiddle.net/cBWsr/2/             var people = this.get('people');
                                        return people.filterProperty('isFemale', true).
                                          get('length');
                                    }.property('people.@each.isFemale')


11
Ember.Object

var App = Ember.Application.create();

App.Person = Em.Object.extend({
  login: null,
  firstName: null,

  changedFirstName: function(){
    this.set('login', this.get('firstName').toLowerCase());
  }.observes('firstName')
});                          Observer

var john = App.Person.create();
john.set('firstName', 'John');
john.get("login"); // john




                                                 http://jsfiddle.net/X7QBU/3/


12
Ember.Object


App = Ember.Application.create({});

App.wife = Ember.Object.create({
  householdIncome: 80000
});

App.husband = Ember.Object.create({
  householdIncomeBinding: 'App.wife.householdIncome'
                                                                Binding
});

Ember.run.later(function() {
  // someone gets a raise
  App.husband.set('householdIncome', 90000);
}, 3000);​
                                                  See the magic inside the view
                                      <script type="text/x-handlebars" >
                                         Wifes income: {{App.wife.householdIncome}}<br/>
                                         Husbands income: {{App.husband.householdIncome}}
http://jsfiddle.net/qQ382/              </script>​




13
Ember.Object




     • Apply for Models
     • Apply for Controllers
     • Apply for Views
     • Apply for (...)



14
Time for Dojo


15
Time for Dojo




     • Already?
     • It will be in a paused way
     • We have so many concepts to discuss




16
Time for Dojo


     todo   doing   verify   done




17
Time for Dojo


     • Scrum board
      • Stories and tasks (executed by a person)
        •   I want to create stories (tasks)

        •   I want to edit stories (tasks)

        •   I want to delete stories (tasks)

        •   I want to assign a task for me

      • No server integration (for now)
                                                       Next dev-day /o/
                                                        (ember-data)
18
Time for Dojo




     • Spoiler: http://jsfiddle.net/37YMc/2/




19
Router


20
Router




     • Maps URLs to states and vice versa
     • Preferred for building large apps
     • Can link views based on the state
     • Loves name conventions



21
Router

App.Router = Ember.Router.extend({
  root: Em.Route.extend({
    contacts: Em.Route.extend({
      route: '/',
      redirectsTo: 'index'

            index: Em.Route.extend({
              route: '/',

        connectOutlets: function(router) {
          router.get('applicationController').connectOutlet('contacts',
App.Contacts.findAll());
        }
      }),

            contact: Em.Route.extend({
              route: '/contacts/:contact_id',

                 connectOutlets: function(router, context) {
                    router.get('contactsController').connectOutlet('contact', context);
                 },
            })
       })
  })
});




22
WTF is outlet?


     ApplicationView                    Name convention


        {{outlet}}
                                   router.get('applicationController').
                                   connectOutlet('contacts', objects);


                 Name convention


                                            Passed objects


      ContactsView
        (objects)

23
C for Controller


24
C for Controller




     • Controller    simple controller

     • ObjectController       support to manipulate
       an Object

     • ArrayController     support to manipulate a
       collection




25
C for Controller

                       Accessing the content
App.ContactController = Em.ObjectController.extend({
  someProperty: 'cool-value',

  destroyRecord: function() {
    this.get('content').destroy();
  }
});




            pushing a object to a controller’s collection

App.ContactsController = Em.ArrayController.extend({
  createContact: function(name) {

         push
     var contact = App.Contact.create({ name: name });
     this.pushObject(contact);
  },
});
                                                                   Remember that all
                                                                binding’s magic apply to
                                                                      Controllers
26
V for View


27
V for View



     • Always associated with a template
     • Your friend when dealing with browser
       events
      • touch (touchStart), keyboard (keyDown),
        mouse (mouseDown), form (submit), drag
        and drop (dragStart),



28
V for View

App.EditContactView = Ember.View.extend({
  templateName: 'edit_contact',
  tagName: 'form',
  classNames: ['form-horizontal'],

     didInsertElement: function() {
                                           DOM event
        this._super();
        this.$('input:first').focus();
     },

  submit: function(event) {
                                       Browser event
    event.preventDefault();
    this.get('controller').updateRecord();
  }
});

                 <script type="text/x-handlebars" data-template-name="edit_contact">
                    {{ view Ember.TextArea }}
                    <button class="button-primary" type="submit">Enviar</button>
                 </script>




29
Handlebars
        helpers

30
Handlebars helpers




     • {{#if}}
     • {{#each}}
     • {{view}}
     • {{action}}



31
Final doubts


32
References




     • http://emberjs.com/ (updated
       yesterday!)
     • http://emberwatch.com/




33
Thanks. /o/

        Juliana Lucena


34

More Related Content

What's hot (20)

Javascript Module Patterns
Javascript Module PatternsJavascript Module Patterns
Javascript Module Patterns
Nicholas Jansma
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.js
Bert Wijnants
 
Angular 1 + es6
Angular 1 + es6Angular 1 + es6
Angular 1 + es6
장현 한
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
Visual Engineering
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
Eyal Vardi
 
Workshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsWorkshop 3: JavaScript build tools
Workshop 3: JavaScript build tools
Visual Engineering
 
Backbone.js and friends
Backbone.js and friendsBackbone.js and friends
Backbone.js and friends
Good Robot
 
Intro to Ember.js
Intro to Ember.jsIntro to Ember.js
Intro to Ember.js
Jay Phelps
 
«От экспериментов с инфраструктурой до внедрения в продакшен»​
«От экспериментов с инфраструктурой до внедрения в продакшен»​«От экспериментов с инфраструктурой до внедрения в продакшен»​
«От экспериментов с инфраструктурой до внедрения в продакшен»​
FDConf
 
AngularJS for Java Developers
AngularJS for Java DevelopersAngularJS for Java Developers
AngularJS for Java Developers
Loc Nguyen
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
Katy Slemon
 
Workshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJSWorkshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJS
Visual Engineering
 
Building a Startup Stack with AngularJS
Building a Startup Stack with AngularJSBuilding a Startup Stack with AngularJS
Building a Startup Stack with AngularJS
FITC
 
Vue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMRVue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMR
Javier Abadía
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.
Visual Engineering
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to production
FDConf
 
AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
Sergey Bolshchikov
 
Drupal 8: Fields reborn
Drupal 8: Fields rebornDrupal 8: Fields reborn
Drupal 8: Fields reborn
Pablo López Escobés
 
Introduction to Node.JS Express
Introduction to Node.JS ExpressIntroduction to Node.JS Express
Introduction to Node.JS Express
Eueung Mulyana
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
VO Tho
 
Javascript Module Patterns
Javascript Module PatternsJavascript Module Patterns
Javascript Module Patterns
Nicholas Jansma
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.js
Bert Wijnants
 
Angular 1 + es6
Angular 1 + es6Angular 1 + es6
Angular 1 + es6
장현 한
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
Visual Engineering
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
Eyal Vardi
 
Workshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsWorkshop 3: JavaScript build tools
Workshop 3: JavaScript build tools
Visual Engineering
 
Backbone.js and friends
Backbone.js and friendsBackbone.js and friends
Backbone.js and friends
Good Robot
 
Intro to Ember.js
Intro to Ember.jsIntro to Ember.js
Intro to Ember.js
Jay Phelps
 
«От экспериментов с инфраструктурой до внедрения в продакшен»​
«От экспериментов с инфраструктурой до внедрения в продакшен»​«От экспериментов с инфраструктурой до внедрения в продакшен»​
«От экспериментов с инфраструктурой до внедрения в продакшен»​
FDConf
 
AngularJS for Java Developers
AngularJS for Java DevelopersAngularJS for Java Developers
AngularJS for Java Developers
Loc Nguyen
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
Katy Slemon
 
Workshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJSWorkshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJS
Visual Engineering
 
Building a Startup Stack with AngularJS
Building a Startup Stack with AngularJSBuilding a Startup Stack with AngularJS
Building a Startup Stack with AngularJS
FITC
 
Vue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMRVue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMR
Javier Abadía
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.
Visual Engineering
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to production
FDConf
 
Introduction to Node.JS Express
Introduction to Node.JS ExpressIntroduction to Node.JS Express
Introduction to Node.JS Express
Eueung Mulyana
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
VO Tho
 

Similar to Ember.js - A JavaScript framework for creating ambitious web applications (20)

Introduction to Ember.js
Introduction to Ember.jsIntroduction to Ember.js
Introduction to Ember.js
Vinoth Kumar
 
Ember vs Backbone
Ember vs BackboneEmber vs Backbone
Ember vs Backbone
Abdriy Mosin
 
Parse Apps with Ember.js
Parse Apps with Ember.jsParse Apps with Ember.js
Parse Apps with Ember.js
Matthew Beale
 
Ember.js: Jump Start
Ember.js: Jump Start Ember.js: Jump Start
Ember.js: Jump Start
Viacheslav Bukach
 
Introduction to Ember.js
Introduction to Ember.jsIntroduction to Ember.js
Introduction to Ember.js
Jeremy Brown
 
Using Ember to Make a Bazillion Dollars
Using Ember to Make a Bazillion DollarsUsing Ember to Make a Bazillion Dollars
Using Ember to Make a Bazillion Dollars
Mike Pack
 
Create an application with ember
Create an application with ember Create an application with ember
Create an application with ember
Chandra Sekar
 
Ember.js for a CakePHP Developer
Ember.js for a CakePHP DeveloperEmber.js for a CakePHP Developer
Ember.js for a CakePHP Developer
jtrapp07
 
Intro to Ember.JS 2016
Intro to Ember.JS 2016Intro to Ember.JS 2016
Intro to Ember.JS 2016
Sandino Núñez
 
Getting into ember.js
Getting into ember.jsGetting into ember.js
Getting into ember.js
reybango
 
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Matt Raible
 
Introduction to ember js
Introduction to ember jsIntroduction to ember js
Introduction to ember js
Adnan Arshad
 
An introduction to Ember.js
An introduction to Ember.jsAn introduction to Ember.js
An introduction to Ember.js
codeofficer
 
Introduction to Ember
Introduction to EmberIntroduction to Ember
Introduction to Ember
SmartLogic
 
Building Ambitious Web Apps with Ember
Building Ambitious Web Apps with EmberBuilding Ambitious Web Apps with Ember
Building Ambitious Web Apps with Ember
gbabiars
 
Riding the Edge with Ember.js
Riding the Edge with Ember.jsRiding the Edge with Ember.js
Riding the Edge with Ember.js
aortbals
 
Ember.js for SFHTML5
Ember.js for SFHTML5Ember.js for SFHTML5
Ember.js for SFHTML5
Anthony Bull
 
Ember.js for Big Profit
Ember.js for Big ProfitEmber.js for Big Profit
Ember.js for Big Profit
CodeCore
 
Emberjs and ASP.NET
Emberjs and ASP.NETEmberjs and ASP.NET
Emberjs and ASP.NET
Mike Melusky
 
Ember.js 101 - JSChannel NCR
Ember.js 101 - JSChannel NCREmber.js 101 - JSChannel NCR
Ember.js 101 - JSChannel NCR
Achal Aggarwal
 
Introduction to Ember.js
Introduction to Ember.jsIntroduction to Ember.js
Introduction to Ember.js
Vinoth Kumar
 
Parse Apps with Ember.js
Parse Apps with Ember.jsParse Apps with Ember.js
Parse Apps with Ember.js
Matthew Beale
 
Introduction to Ember.js
Introduction to Ember.jsIntroduction to Ember.js
Introduction to Ember.js
Jeremy Brown
 
Using Ember to Make a Bazillion Dollars
Using Ember to Make a Bazillion DollarsUsing Ember to Make a Bazillion Dollars
Using Ember to Make a Bazillion Dollars
Mike Pack
 
Create an application with ember
Create an application with ember Create an application with ember
Create an application with ember
Chandra Sekar
 
Ember.js for a CakePHP Developer
Ember.js for a CakePHP DeveloperEmber.js for a CakePHP Developer
Ember.js for a CakePHP Developer
jtrapp07
 
Getting into ember.js
Getting into ember.jsGetting into ember.js
Getting into ember.js
reybango
 
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Matt Raible
 
Introduction to ember js
Introduction to ember jsIntroduction to ember js
Introduction to ember js
Adnan Arshad
 
An introduction to Ember.js
An introduction to Ember.jsAn introduction to Ember.js
An introduction to Ember.js
codeofficer
 
Introduction to Ember
Introduction to EmberIntroduction to Ember
Introduction to Ember
SmartLogic
 
Building Ambitious Web Apps with Ember
Building Ambitious Web Apps with EmberBuilding Ambitious Web Apps with Ember
Building Ambitious Web Apps with Ember
gbabiars
 
Riding the Edge with Ember.js
Riding the Edge with Ember.jsRiding the Edge with Ember.js
Riding the Edge with Ember.js
aortbals
 
Ember.js for SFHTML5
Ember.js for SFHTML5Ember.js for SFHTML5
Ember.js for SFHTML5
Anthony Bull
 
Ember.js for Big Profit
Ember.js for Big ProfitEmber.js for Big Profit
Ember.js for Big Profit
CodeCore
 
Emberjs and ASP.NET
Emberjs and ASP.NETEmberjs and ASP.NET
Emberjs and ASP.NET
Mike Melusky
 
Ember.js 101 - JSChannel NCR
Ember.js 101 - JSChannel NCREmber.js 101 - JSChannel NCR
Ember.js 101 - JSChannel NCR
Achal Aggarwal
 
Ad

Recently uploaded (20)

Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
Cisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdfCisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdf
superdpz
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
Cisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdfCisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdf
superdpz
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Ad

Ember.js - A JavaScript framework for creating ambitious web applications

  • 1. Dev-day Ember.js A JavaScript framework for creating ambitious web applications Juliana Lucena 26 Oct 2012
  • 2. Why? • Clearly separate back-end and front- end • Faster user app interaction • Makes your life easier :) 2
  • 3. Ember.js • Browser based MVC framework • Eliminates boilerplate • Provides architecture • Based on event propagation 3
  • 4. Dependencies • jQuery • Handlebars.js - Template language <script type="text/x-handlebars" data-template-name="answer"> <a href="#" class="author-name">{{ answer.author.name }}</a> <span class="status-info">respondeu:</span> {{#if answer.created_at}} {{datetime answer.created_at}} {{/if}} <p class="input-user">{{ answer.content.text }}</p> </script> 4
  • 5. Examples • http://emberjs.com/examples/ • https://github.com/dgeb/ ember_data_example 5
  • 7. MVC Workflow User Notifies Model action View Updates Controller Updates • Tracks the app’s state Router • Affects the application’s view hierarchy • Mediates between the MVC components Serialize URL Usable app state Deserialize 7
  • 8. Hello Redu var App = Em.Application.create(); App.ApplicationView = Em.View.extend({ templateName: 'application' }); App.ApplicationController = Em.View.extend({! }); App.Router = Em.Router.extend({ index.html root: Ember.Route.extend({ (...) index: Ember.Route.extend({ <body> route: '/' <script type="text/x-handlebars" }) data-template-name="application"> }) <h1>Hello Redu! (chuckle)</h1> }); </script> </body> (...) App.initialize(); http://jsfiddle.net/x8zpH/1/ 8
  • 9. M for Model Ember.Object 9
  • 10. Ember.Object • Enhanced JavaScript object model • Computed Properties (synthetizes properties) • Observers (reacts to changes) • Bindings (syncs objects) Always access properties using get and set 10
  • 11. Ember.Object var App = Ember.Application.create(); App.Person = Em.Object.extend({ firstName: null, lastName: null, fullName: function(){ return this.get('firstName') + " " + this.get('lastName'); }.property('firstName', 'lastName') }); Computed Property var john = App.Person.create({ firstName: "John", lastName: "Doe" }); john.get("fullName"); // John Doe What about computed property for arrays, hãn? femalesCount: function() { http://jsfiddle.net/cBWsr/2/ var people = this.get('people'); return people.filterProperty('isFemale', true). get('length'); }.property('[email protected]') 11
  • 12. Ember.Object var App = Ember.Application.create(); App.Person = Em.Object.extend({ login: null, firstName: null, changedFirstName: function(){ this.set('login', this.get('firstName').toLowerCase()); }.observes('firstName') }); Observer var john = App.Person.create(); john.set('firstName', 'John'); john.get("login"); // john http://jsfiddle.net/X7QBU/3/ 12
  • 13. Ember.Object App = Ember.Application.create({}); App.wife = Ember.Object.create({ householdIncome: 80000 }); App.husband = Ember.Object.create({ householdIncomeBinding: 'App.wife.householdIncome' Binding }); Ember.run.later(function() { // someone gets a raise App.husband.set('householdIncome', 90000); }, 3000);​ See the magic inside the view <script type="text/x-handlebars" > Wifes income: {{App.wife.householdIncome}}<br/> Husbands income: {{App.husband.householdIncome}} http://jsfiddle.net/qQ382/ </script>​ 13
  • 14. Ember.Object • Apply for Models • Apply for Controllers • Apply for Views • Apply for (...) 14
  • 16. Time for Dojo • Already? • It will be in a paused way • We have so many concepts to discuss 16
  • 17. Time for Dojo todo doing verify done 17
  • 18. Time for Dojo • Scrum board • Stories and tasks (executed by a person) • I want to create stories (tasks) • I want to edit stories (tasks) • I want to delete stories (tasks) • I want to assign a task for me • No server integration (for now) Next dev-day /o/ (ember-data) 18
  • 19. Time for Dojo • Spoiler: http://jsfiddle.net/37YMc/2/ 19
  • 21. Router • Maps URLs to states and vice versa • Preferred for building large apps • Can link views based on the state • Loves name conventions 21
  • 22. Router App.Router = Ember.Router.extend({ root: Em.Route.extend({ contacts: Em.Route.extend({ route: '/', redirectsTo: 'index' index: Em.Route.extend({ route: '/', connectOutlets: function(router) { router.get('applicationController').connectOutlet('contacts', App.Contacts.findAll()); } }), contact: Em.Route.extend({ route: '/contacts/:contact_id', connectOutlets: function(router, context) { router.get('contactsController').connectOutlet('contact', context); }, }) }) }) }); 22
  • 23. WTF is outlet? ApplicationView Name convention {{outlet}} router.get('applicationController'). connectOutlet('contacts', objects); Name convention Passed objects ContactsView (objects) 23
  • 25. C for Controller • Controller simple controller • ObjectController support to manipulate an Object • ArrayController support to manipulate a collection 25
  • 26. C for Controller Accessing the content App.ContactController = Em.ObjectController.extend({ someProperty: 'cool-value', destroyRecord: function() { this.get('content').destroy(); } }); pushing a object to a controller’s collection App.ContactsController = Em.ArrayController.extend({ createContact: function(name) { push var contact = App.Contact.create({ name: name }); this.pushObject(contact); }, }); Remember that all binding’s magic apply to Controllers 26
  • 28. V for View • Always associated with a template • Your friend when dealing with browser events • touch (touchStart), keyboard (keyDown), mouse (mouseDown), form (submit), drag and drop (dragStart), 28
  • 29. V for View App.EditContactView = Ember.View.extend({ templateName: 'edit_contact', tagName: 'form', classNames: ['form-horizontal'], didInsertElement: function() { DOM event this._super(); this.$('input:first').focus(); }, submit: function(event) { Browser event event.preventDefault(); this.get('controller').updateRecord(); } }); <script type="text/x-handlebars" data-template-name="edit_contact"> {{ view Ember.TextArea }} <button class="button-primary" type="submit">Enviar</button> </script> 29
  • 30. Handlebars helpers 30
  • 31. Handlebars helpers • {{#if}} • {{#each}} • {{view}} • {{action}} 31
  • 33. References • http://emberjs.com/ (updated yesterday!) • http://emberwatch.com/ 33
  • 34. Thanks. /o/ Juliana Lucena 34