SlideShare a Scribd company logo
1 of 43
Download to read offline
Raúl Delgado & Andrés Lamilla
Front End Workshops
EmberJS General Overview
rdelgado@visual-engin.com
alamilla@visual-engin.com
A framework for creating ambitious
web applications.
● Focus on ambitious web applications: applications that look and act
like desktop applications, but happen to be delivered via web
technologies
● More productive out of the box: provide a complete development
stack to make the developer productive immediately. (Ember CLI,
application structure, thousands addons).
● Stability without stagnation: backward compatibility is important and
can be maintained while still innovating and evolving the framework.
● Future web standards foresight: pioneer of many standards around
Javascript and the web. (promises, web components and ES6 syntax)
Philosophy
● Routes: the state of an application is represented by a URL
● Models: data associated with the current state of the application
● Templates: HTMLBars templating language. (Handlebars
variation)
● Components: custom HTML tag
● Services: singleton objects to hold long-lived data such as user
sessions
Five essential Concepts
Big Picture
● In December 2011, the SproutCore 2.0 framework was renamed to Ember.js
● The framework was created by Yehuda Katz, a member of the jQuery, Ruby
on Rails and SproutCore core teams
● Ember follows a six-week release cycle. Every six weeks a new release is
made available, and at the same time a beta for the next release is also
published
● Ember follows the semantic versioning convention. This means that breaking
changes are only introduced at major version numbers such as 1.0, 2.0 etc.
● Ember 2.0 was released August 13, 2015. Introduction of the Glimmer
rendering engine
● It follows the Convention over configuration design paradigm
● Stable release 2.4.3 / March 17, 2016
Facts
Ember cli
● Strong conventional project structure
● Powerful addon system for extension
● Uses babel, which turns ES2015 module syntax into AMD (RequireJS-esq)
modules.
● Use QUnit and Ember QUnit by default. But, you are free to use other options
such as Mocha and Ember Mocha.
● Use Bower, for front-end dependencies and npm, for managing internal
dependencies
● Is configurable via a file named .ember-cli
Ember cli
Has support for:
● Handlebars
● HTMLBars
● Emblem
● LESS
● Sass
● Compass
● Stylus
● CoffeeScript
● EmberScript
● Minified JS & CSS
Ember cli
Commands:
● ember
● ember new <app-name>
● ember init
● ember build
● ember server
● ember generate <generator-name> <options>
● ember help generate
● ember destroy <generator-name> <options>
● ember test
● ember install <addon-name>
Ember cli
npm install -g ember-cli@2.4
ember new ember-quickstart
cd ember-quickstart
ember serve
Livereload server on http://localhost:49152
Serving on http://localhost:4200/
ember generate route scientists
installing route
create app/routes/scientists.js
create app/templates/scientists.hbs
updating router
add route scientists
installing route-test
create tests/unit/routes/scientists-test.js
ember build --env production
Ember cli
ember install ember-cli-sass
ember install ember-cli-bootstrap-sassy
mv app/styles/app.css app/styles/app.scss
echo '@import "bootstrap";' > app/styles/app.scss
Ember cli
Ember.object
Ember implements its own object system. The base object is Ember.Object.
All of the other objects in Ember extend Ember.Object.
Ember.Object can observe properties change.
This simple architectural decision is responsible for much of the consistency
across Ember. Every Ember object can observe the properties of other
objects, bind their properties to the properties of other objects, specify and
update computed properties, and much more.
This gives enormous power and flexibility !
Ember.object
Ember.object vs JS object
Defining new Ember Class:
Ember.object
Properties:
person1 = Person.extend({
firstName: “John”,
lastName: “McClaine”,
fullName(): {
let fullName = this.firstName + ‘ ’ + this.lastName;
alert(`my name is ${fullName} !`)
}
})
person1.get(‘firstName’) //John
person1.get(‘lastName’) //McClane
person1.fullName()
//my name is John Mclane !
Person = Ember.Object.extend()
user = Person.create()
Observers:
Ember.object
Person = Ember.Object.extend({
firstName: null,
lastName: null,
fullName: Ember.computed( 'firstName', 'lastName', function() {
return `${this.get('firstName')} ${this.get('lastName')}`;
}),
fullNameChanged: Ember.observer( 'fullName', () => {
// deal with the change
console.log(`fullName changed to: ${this.get('fullName')}`);
})
})
var person = Person.create({
firstName : Harry,
lastName : ‘Stamper’
})
person.get(‘fullName’) // Harry Stamper
person.set(‘firstName’, “Grace”)
// fullName changet to: Grace Stamper
Models
The models are objects that represent the underlying data that the application
presents the user. Different applications have very different models,
depending on what are the problems they are trying to solve.
You can create a model with the command:
This will generate:
Models
$ ember generate model person
Models
Defining attributes:
To define attributes to our model, we have four methods:
- Attr
- hasMany
- belonsTo
- normalizeModelName
attr:
Models
Relationship methods: hasMany & belongsTo:
One-to-one:
One-to-many:
Many-to-many:
Routing
Ember is URL-driven so it always starts in the
URL. In the example, our router has the
following definition:
Routing
An instance of the Route invoke the model() method where we turn the model.
Here it looks like a dummy object is returned:
Once model() has been returned, the
renderComponent() method call
ItemDisplayComponent model.
Not only push data paths. They can also
receive actions.
Actions are sent from components or other
routes, so that the logic transitions involving
URL or another route-level issue.
Routing
Routing
What’s going on here?
1. The Router parses the /items/2 URL and dispatches
control to a matching route: ItemRoute with a
parameter item_id=2
2. ItemRoute invokes its model() hook, in which our
app returns a model (Item with id=2) fetched via a
service
3. renderComponent() is then run to render the
component ItemDisplayComponent, passing it the
resolved model Item
4. ItemDisplayComponent is responsible for the user
interface: rendering/updating the DOM, and handling
browser events
The application route is entered when your app first boots up. Like other routes, it will load a
template with the same name (application in this case) by default. You should put your header,
footer, and any other decorative content here. All other routes will render their templates into the
application.hbs template's {{outlet}}.
This route is part of every application, so you don't need to specify it in your app/router.js.
Routing
The application route:
Index Routes:
At every level of nesting (including the top level),
Ember automatically provides a route for the /
path named index.
Templates
app/helpers/sum.js
export function sum(params) {
return params.reduce((a, b) => {
return a + b;
});
};
export default Ember.Helper.helper(sum);
Templates
<p>Total: {{sum 1 2 3}}</p>
{{sum (multiply 2 4) 2}}
<div>
{{if isFast "I am fast" "I am slow"}}
</div>
Templates
<div>
{{if isFast (if isFueled "zoooom")}}
</div>
{{#if isAtWork}}
Ship that code!
{{else if isReading}}
You can finish War and Peace eventually...
{{/if}}
{{#each people as |person|}}
Hello, {{person.name}}!
{{else}}
Sorry, nobody is here.
{{/each}}
Templates
<ul>
{{#each people as |person index|}}
<li>Hello, {{person.name}}! You're number {{index}} in line</li>
{{/each}}
</ul>
/app/components/store-categories.js
export default Ember.Component.extend({
willRender() {
this.set('categories', {
'Bourbons': ['Bulleit', 'Four Roses', 'Woodford Reserve'],
'Ryes': ['WhistlePig', 'High West']
});
}
});
Templates
/app/templates/components/store-categories.hbs
<ul>
{{#each-in categories as |category products|}}
<li>{{category}}
<ol>
{{#each products as |product|}}
<li>{{product}}</li>
{{/each}}
</ol>
</li>
{{/each-in}}
</ul>
<ul>
<li>Bourbons
<ol>
<li>Bulleit</li>
<li>Four Roses</li>
<li>Woodford Reserve</li>
</ol>
</li>
<li>Ryes
<ol>
<li>WhistlePig</li>
<li>High West</li>
</ol>
</li>
</ul>
/app/components/store-categories.js
export default Ember.Component.extend({
willRender() {
this.set('categories', {
'Bourbons': ['Bulleit', 'Four Roses', 'Woodford Reserve'],
'Ryes': ['WhistlePig', 'High West']
});
},
actions: {
addCategory(category) {
let categories = this.get('categories');
categories[category] = [ ];
// A manual re-render causes the DOM to be updated
this.rerender();
}
}
});
Templates
app/templates/components/single-post.hbs
<p><button {{action "select" post}}>✓</button> {{post.title}}</p>
Templates
app/components/single-post.js
export default Ember.Component.extend({
actions: {
select(post) {
console.log(post.get('title'));
}
}
});
app/templates/components/single-post.hbs
<p>
<button {{action "select" post on="mouseUp"}}>✓</button>
{{post.title}}
</p>
Components
ember generate component my-component-name
installing component
create app/components/my-component-name.js
create app/templates/components/my-component-name.hbs
installing component-test
create tests/integration/components/my-component-name-test.js
Components
app/templates/components/blog-post.hbs
<article class="blog-post">
<h1>{{title}}</h1>
<p>{{yield}}</p>
<p>Edit title: {{input type="text" value=title}}</p>
</article>
app/templates/index.hbs
{{#each model as |post|}}
{{#blog-post title=post.title}}
{{post.body}}
{{/blog-post}}
{{/each}}
app/routes/index.js
export default Ember.Route.extend({
model() {
return this.store.findAll('post');
}
});
https://ember-twiddle.com/7ff20a68a367df12a894294d837bc391?openFiles=controllers.application.js%2Cblog-post.template.
hbs
Controllers
A controller is a routable object meant to “decorate” a model with display
logic.
Controllers
A controller is a routable object meant to “decorate” a model with display
logic.
Controllers
Ember CLI Mirage
Mirage
Ember CLI Mirage is a client side mock server to develop and prototype
applications.
Fixtures and Factories
We now have a couple of choices. We can create data using fixtures, or
generate them through a factory. It's probably a good idea to use factories.
They can easily be added to your tests.
Fixtures
Mirage
Factories
More information in...
● https://guides.emberjs.com/v2.4.0/
● http://emberjs.com/api/
● https://ember-twiddle.com/
● http://emberigniter.com/
● http://yoember.com/
Workshop 16: EmberJS Parte I

More Related Content

What's hot

Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architectureMichael He
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedStéphane Bégaudeau
 
Building a Startup Stack with AngularJS
Building a Startup Stack with AngularJSBuilding a Startup Stack with AngularJS
Building a Startup Stack with AngularJSFITC
 
AngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UXAngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UXJWORKS powered by Ordina
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)Gary Arora
 
Angularjs - lazy loading techniques
Angularjs - lazy loading techniques Angularjs - lazy loading techniques
Angularjs - lazy loading techniques Nir Kaufman
 
Angular Lazy Loading and Resolve (Route Resolver)
Angular Lazy Loading and Resolve (Route Resolver)Angular Lazy Loading and Resolve (Route Resolver)
Angular Lazy Loading and Resolve (Route Resolver)Squash Apps Pvt Ltd
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSSimon Guest
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introductionTania Gonzales
 
AngularJS for Java Developers
AngularJS for Java DevelopersAngularJS for Java Developers
AngularJS for Java DevelopersLoc Nguyen
 
AngularJS for designers and developers
AngularJS for designers and developersAngularJS for designers and developers
AngularJS for designers and developersKai Koenig
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - IntroductionSagar Acharya
 

What's hot (20)

Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
 
Workshop 21: React Router
Workshop 21: React RouterWorkshop 21: React Router
Workshop 21: React Router
 
Angularjs
AngularjsAngularjs
Angularjs
 
Angular js
Angular jsAngular js
Angular js
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
Building a Startup Stack with AngularJS
Building a Startup Stack with AngularJSBuilding a Startup Stack with AngularJS
Building a Startup Stack with AngularJS
 
AngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UXAngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UX
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)
 
Angularjs - lazy loading techniques
Angularjs - lazy loading techniques Angularjs - lazy loading techniques
Angularjs - lazy loading techniques
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Angular Lazy Loading and Resolve (Route Resolver)
Angular Lazy Loading and Resolve (Route Resolver)Angular Lazy Loading and Resolve (Route Resolver)
Angular Lazy Loading and Resolve (Route Resolver)
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
 
AngularJS for Java Developers
AngularJS for Java DevelopersAngularJS for Java Developers
AngularJS for Java Developers
 
AngularJS for designers and developers
AngularJS for designers and developersAngularJS for designers and developers
AngularJS for designers and developers
 
AngularJS Basic Training
AngularJS Basic TrainingAngularJS Basic Training
AngularJS Basic Training
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 

Viewers also liked

Change document display
Change document displayChange document display
Change document displayRadosław Gref
 
Workshop iOS 3: Testing, protocolos y extensiones
Workshop iOS 3: Testing, protocolos y extensionesWorkshop iOS 3: Testing, protocolos y extensiones
Workshop iOS 3: Testing, protocolos y extensionesVisual Engineering
 
Unlock The Value Of Your Microsoft and SAP Investments
Unlock The Value Of Your Microsoft and SAP InvestmentsUnlock The Value Of Your Microsoft and SAP Investments
Unlock The Value Of Your Microsoft and SAP InvestmentsSAP Technology
 
Workshop iOS 4: Closures, generics & operators
Workshop iOS 4: Closures, generics & operatorsWorkshop iOS 4: Closures, generics & operators
Workshop iOS 4: Closures, generics & operatorsVisual Engineering
 
Workshop 11: Trendy web designs & prototyping
Workshop 11: Trendy web designs & prototypingWorkshop 11: Trendy web designs & prototyping
Workshop 11: Trendy web designs & prototypingVisual Engineering
 
Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101Tim Penhey
 
JavaScript for ABAP Programmers - 7/7 Functional Programming
JavaScript for ABAP Programmers - 7/7 Functional ProgrammingJavaScript for ABAP Programmers - 7/7 Functional Programming
JavaScript for ABAP Programmers - 7/7 Functional ProgrammingChris Whealy
 
Workshop 24: React Native Introduction
Workshop 24: React Native IntroductionWorkshop 24: React Native Introduction
Workshop 24: React Native IntroductionVisual Engineering
 
Automated Testing Of Web Applications Using XML
Automated  Testing Of  Web  Applications Using  XMLAutomated  Testing Of  Web  Applications Using  XML
Automated Testing Of Web Applications Using XMLdiongillard
 
Getting Started with OpenUI5 (San Francisco State University)
Getting Started with OpenUI5 (San Francisco State University)Getting Started with OpenUI5 (San Francisco State University)
Getting Started with OpenUI5 (San Francisco State University)Alexander Graebe
 
SAP for Utilities 2015 FINAL HOTLIST
SAP for Utilities 2015 FINAL HOTLISTSAP for Utilities 2015 FINAL HOTLIST
SAP for Utilities 2015 FINAL HOTLISTJonathan Toomey
 
Introduction to Design Thinking
Introduction to Design ThinkingIntroduction to Design Thinking
Introduction to Design ThinkingBlackvard
 
Workhop iOS 1: Fundamentos de Swift
Workhop iOS 1: Fundamentos de SwiftWorkhop iOS 1: Fundamentos de Swift
Workhop iOS 1: Fundamentos de SwiftVisual Engineering
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IVisual Engineering
 
Consuming Data With HANA XS
Consuming Data With HANA XSConsuming Data With HANA XS
Consuming Data With HANA XSBlackvard
 
Workshop 25: React Native - Components
Workshop 25: React Native - ComponentsWorkshop 25: React Native - Components
Workshop 25: React Native - ComponentsVisual Engineering
 

Viewers also liked (20)

Change document display
Change document displayChange document display
Change document display
 
Workshop iOS 3: Testing, protocolos y extensiones
Workshop iOS 3: Testing, protocolos y extensionesWorkshop iOS 3: Testing, protocolos y extensiones
Workshop iOS 3: Testing, protocolos y extensiones
 
Unlock The Value Of Your Microsoft and SAP Investments
Unlock The Value Of Your Microsoft and SAP InvestmentsUnlock The Value Of Your Microsoft and SAP Investments
Unlock The Value Of Your Microsoft and SAP Investments
 
CDS Unit Testing
CDS Unit TestingCDS Unit Testing
CDS Unit Testing
 
Workshop iOS 4: Closures, generics & operators
Workshop iOS 4: Closures, generics & operatorsWorkshop iOS 4: Closures, generics & operators
Workshop iOS 4: Closures, generics & operators
 
Workshop 11: Trendy web designs & prototyping
Workshop 11: Trendy web designs & prototypingWorkshop 11: Trendy web designs & prototyping
Workshop 11: Trendy web designs & prototyping
 
Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101
 
Hana sql
Hana sql Hana sql
Hana sql
 
JavaScript for ABAP Programmers - 7/7 Functional Programming
JavaScript for ABAP Programmers - 7/7 Functional ProgrammingJavaScript for ABAP Programmers - 7/7 Functional Programming
JavaScript for ABAP Programmers - 7/7 Functional Programming
 
Workshop 24: React Native Introduction
Workshop 24: React Native IntroductionWorkshop 24: React Native Introduction
Workshop 24: React Native Introduction
 
Automated Testing Of Web Applications Using XML
Automated  Testing Of  Web  Applications Using  XMLAutomated  Testing Of  Web  Applications Using  XML
Automated Testing Of Web Applications Using XML
 
Getting Started with OpenUI5 (San Francisco State University)
Getting Started with OpenUI5 (San Francisco State University)Getting Started with OpenUI5 (San Francisco State University)
Getting Started with OpenUI5 (San Francisco State University)
 
Python Intro
Python IntroPython Intro
Python Intro
 
SAP for Utilities 2015 FINAL HOTLIST
SAP for Utilities 2015 FINAL HOTLISTSAP for Utilities 2015 FINAL HOTLIST
SAP for Utilities 2015 FINAL HOTLIST
 
Introduction to Design Thinking
Introduction to Design ThinkingIntroduction to Design Thinking
Introduction to Design Thinking
 
Workhop iOS 1: Fundamentos de Swift
Workhop iOS 1: Fundamentos de SwiftWorkhop iOS 1: Fundamentos de Swift
Workhop iOS 1: Fundamentos de Swift
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte I
 
Consuming Data With HANA XS
Consuming Data With HANA XSConsuming Data With HANA XS
Consuming Data With HANA XS
 
OpenUI5
OpenUI5OpenUI5
OpenUI5
 
Workshop 25: React Native - Components
Workshop 25: React Native - ComponentsWorkshop 25: React Native - Components
Workshop 25: React Native - Components
 

Similar to Workshop 16: EmberJS Parte I

Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails DevsDiacode
 
RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2Rory Gianni
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Introduction to ember js
Introduction to ember jsIntroduction to ember js
Introduction to ember jsAdnan Arshad
 
Introduction to Ember.js
Introduction to Ember.jsIntroduction to Ember.js
Introduction to Ember.jsVinoth Kumar
 
The road to Ember.js 2.0
The road to Ember.js 2.0The road to Ember.js 2.0
The road to Ember.js 2.0Codemotion
 
Create an application with ember
Create an application with ember Create an application with ember
Create an application with ember Chandra Sekar
 
JavaScript Modules Done Right
JavaScript Modules Done RightJavaScript Modules Done Right
JavaScript Modules Done RightMariusz Nowak
 
Building Single Page Application (SPA) with Symfony2 and AngularJS
Building Single Page Application (SPA) with Symfony2 and AngularJSBuilding Single Page Application (SPA) with Symfony2 and AngularJS
Building Single Page Application (SPA) with Symfony2 and AngularJSAntonio Peric-Mazar
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteorSapna Upreti
 
Intro to EmberJS
Intro to EmberJSIntro to EmberJS
Intro to EmberJSBilly Onjea
 
Build Web Apps using Node.js
Build Web Apps using Node.jsBuild Web Apps using Node.js
Build Web Apps using Node.jsdavidchubbs
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsMike Subelsky
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - IntroductionVagmi Mudumbai
 

Similar to Workshop 16: EmberJS Parte I (20)

Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails Devs
 
RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Introduction to ember js
Introduction to ember jsIntroduction to ember js
Introduction to ember js
 
Introduction to Ember.js
Introduction to Ember.jsIntroduction to Ember.js
Introduction to Ember.js
 
Workshop 17: EmberJS parte II
Workshop 17: EmberJS parte IIWorkshop 17: EmberJS parte II
Workshop 17: EmberJS parte II
 
Full slidescr16
Full slidescr16Full slidescr16
Full slidescr16
 
The road to Ember.js 2.0
The road to Ember.js 2.0The road to Ember.js 2.0
The road to Ember.js 2.0
 
GHC
GHCGHC
GHC
 
Create an application with ember
Create an application with ember Create an application with ember
Create an application with ember
 
JavaScript Modules Done Right
JavaScript Modules Done RightJavaScript Modules Done Right
JavaScript Modules Done Right
 
IOC + Javascript
IOC + JavascriptIOC + Javascript
IOC + Javascript
 
Building Single Page Application (SPA) with Symfony2 and AngularJS
Building Single Page Application (SPA) with Symfony2 and AngularJSBuilding Single Page Application (SPA) with Symfony2 and AngularJS
Building Single Page Application (SPA) with Symfony2 and AngularJS
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Intro to EmberJS
Intro to EmberJSIntro to EmberJS
Intro to EmberJS
 
RequireJS
RequireJSRequireJS
RequireJS
 
Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
 
Build Web Apps using Node.js
Build Web Apps using Node.jsBuild Web Apps using Node.js
Build Web Apps using Node.js
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 

More from Visual Engineering

Workshop iOS 2: Swift - Structures
Workshop iOS 2: Swift - StructuresWorkshop iOS 2: Swift - Structures
Workshop iOS 2: Swift - StructuresVisual Engineering
 
Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideVisual Engineering
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingVisual Engineering
 
Workshop 22: ReactJS Redux Advanced
Workshop 22: ReactJS Redux AdvancedWorkshop 22: ReactJS Redux Advanced
Workshop 22: ReactJS Redux AdvancedVisual Engineering
 
Workshop 22: React-Redux Middleware
Workshop 22: React-Redux MiddlewareWorkshop 22: React-Redux Middleware
Workshop 22: React-Redux MiddlewareVisual Engineering
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxVisual Engineering
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionWorkshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionVisual Engineering
 
Workshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effectsWorkshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effectsVisual Engineering
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIVisual Engineering
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIVisual Engineering
 
Workshop 8: Templating: Handlebars, DustJS
Workshop 8: Templating: Handlebars, DustJSWorkshop 8: Templating: Handlebars, DustJS
Workshop 8: Templating: Handlebars, DustJSVisual Engineering
 
Workshop 7: Single Page Applications
Workshop 7: Single Page ApplicationsWorkshop 7: Single Page Applications
Workshop 7: Single Page ApplicationsVisual Engineering
 
Workshop 5: JavaScript testing
Workshop 5: JavaScript testingWorkshop 5: JavaScript testing
Workshop 5: JavaScript testingVisual Engineering
 
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
 
Workshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsWorkshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsVisual Engineering
 

More from Visual Engineering (18)

Workshop iOS 2: Swift - Structures
Workshop iOS 2: Swift - StructuresWorkshop iOS 2: Swift - Structures
Workshop iOS 2: Swift - Structures
 
Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native Side
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
Workshop 22: ReactJS Redux Advanced
Workshop 22: ReactJS Redux AdvancedWorkshop 22: ReactJS Redux Advanced
Workshop 22: ReactJS Redux Advanced
 
Workshop 22: React-Redux Middleware
Workshop 22: React-Redux MiddlewareWorkshop 22: React-Redux Middleware
Workshop 22: React-Redux Middleware
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & Redux
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionWorkshop 19: ReactJS Introduction
Workshop 19: ReactJS Introduction
 
Workshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effectsWorkshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effects
 
Workshop 15: Ionic framework
Workshop 15: Ionic frameworkWorkshop 15: Ionic framework
Workshop 15: Ionic framework
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte III
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte II
 
Workshop 8: Templating: Handlebars, DustJS
Workshop 8: Templating: Handlebars, DustJSWorkshop 8: Templating: Handlebars, DustJS
Workshop 8: Templating: Handlebars, DustJS
 
Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
 
Workshop 7: Single Page Applications
Workshop 7: Single Page ApplicationsWorkshop 7: Single Page Applications
Workshop 7: Single Page Applications
 
Workshop 6: Designer tools
Workshop 6: Designer toolsWorkshop 6: Designer tools
Workshop 6: Designer tools
 
Workshop 5: JavaScript testing
Workshop 5: JavaScript testingWorkshop 5: JavaScript testing
Workshop 5: JavaScript testing
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.
 
Workshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsWorkshop 3: JavaScript build tools
Workshop 3: JavaScript build tools
 

Recently uploaded

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 

Recently uploaded (20)

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 

Workshop 16: EmberJS Parte I

  • 1. Raúl Delgado & Andrés Lamilla Front End Workshops EmberJS General Overview rdelgado@visual-engin.com alamilla@visual-engin.com
  • 2. A framework for creating ambitious web applications.
  • 3. ● Focus on ambitious web applications: applications that look and act like desktop applications, but happen to be delivered via web technologies ● More productive out of the box: provide a complete development stack to make the developer productive immediately. (Ember CLI, application structure, thousands addons). ● Stability without stagnation: backward compatibility is important and can be maintained while still innovating and evolving the framework. ● Future web standards foresight: pioneer of many standards around Javascript and the web. (promises, web components and ES6 syntax) Philosophy
  • 4. ● Routes: the state of an application is represented by a URL ● Models: data associated with the current state of the application ● Templates: HTMLBars templating language. (Handlebars variation) ● Components: custom HTML tag ● Services: singleton objects to hold long-lived data such as user sessions Five essential Concepts
  • 6. ● In December 2011, the SproutCore 2.0 framework was renamed to Ember.js ● The framework was created by Yehuda Katz, a member of the jQuery, Ruby on Rails and SproutCore core teams ● Ember follows a six-week release cycle. Every six weeks a new release is made available, and at the same time a beta for the next release is also published ● Ember follows the semantic versioning convention. This means that breaking changes are only introduced at major version numbers such as 1.0, 2.0 etc. ● Ember 2.0 was released August 13, 2015. Introduction of the Glimmer rendering engine ● It follows the Convention over configuration design paradigm ● Stable release 2.4.3 / March 17, 2016 Facts
  • 8. ● Strong conventional project structure ● Powerful addon system for extension ● Uses babel, which turns ES2015 module syntax into AMD (RequireJS-esq) modules. ● Use QUnit and Ember QUnit by default. But, you are free to use other options such as Mocha and Ember Mocha. ● Use Bower, for front-end dependencies and npm, for managing internal dependencies ● Is configurable via a file named .ember-cli Ember cli
  • 9. Has support for: ● Handlebars ● HTMLBars ● Emblem ● LESS ● Sass ● Compass ● Stylus ● CoffeeScript ● EmberScript ● Minified JS & CSS Ember cli
  • 10. Commands: ● ember ● ember new <app-name> ● ember init ● ember build ● ember server ● ember generate <generator-name> <options> ● ember help generate ● ember destroy <generator-name> <options> ● ember test ● ember install <addon-name> Ember cli
  • 11. npm install -g ember-cli@2.4 ember new ember-quickstart cd ember-quickstart ember serve Livereload server on http://localhost:49152 Serving on http://localhost:4200/ ember generate route scientists installing route create app/routes/scientists.js create app/templates/scientists.hbs updating router add route scientists installing route-test create tests/unit/routes/scientists-test.js ember build --env production Ember cli
  • 12. ember install ember-cli-sass ember install ember-cli-bootstrap-sassy mv app/styles/app.css app/styles/app.scss echo '@import "bootstrap";' > app/styles/app.scss Ember cli
  • 14. Ember implements its own object system. The base object is Ember.Object. All of the other objects in Ember extend Ember.Object. Ember.Object can observe properties change. This simple architectural decision is responsible for much of the consistency across Ember. Every Ember object can observe the properties of other objects, bind their properties to the properties of other objects, specify and update computed properties, and much more. This gives enormous power and flexibility ! Ember.object
  • 16. Defining new Ember Class: Ember.object Properties: person1 = Person.extend({ firstName: “John”, lastName: “McClaine”, fullName(): { let fullName = this.firstName + ‘ ’ + this.lastName; alert(`my name is ${fullName} !`) } }) person1.get(‘firstName’) //John person1.get(‘lastName’) //McClane person1.fullName() //my name is John Mclane ! Person = Ember.Object.extend() user = Person.create()
  • 17. Observers: Ember.object Person = Ember.Object.extend({ firstName: null, lastName: null, fullName: Ember.computed( 'firstName', 'lastName', function() { return `${this.get('firstName')} ${this.get('lastName')}`; }), fullNameChanged: Ember.observer( 'fullName', () => { // deal with the change console.log(`fullName changed to: ${this.get('fullName')}`); }) }) var person = Person.create({ firstName : Harry, lastName : ‘Stamper’ }) person.get(‘fullName’) // Harry Stamper person.set(‘firstName’, “Grace”) // fullName changet to: Grace Stamper
  • 19. The models are objects that represent the underlying data that the application presents the user. Different applications have very different models, depending on what are the problems they are trying to solve. You can create a model with the command: This will generate: Models $ ember generate model person
  • 20. Models Defining attributes: To define attributes to our model, we have four methods: - Attr - hasMany - belonsTo - normalizeModelName attr:
  • 21. Models Relationship methods: hasMany & belongsTo: One-to-one: One-to-many: Many-to-many:
  • 23. Ember is URL-driven so it always starts in the URL. In the example, our router has the following definition: Routing An instance of the Route invoke the model() method where we turn the model. Here it looks like a dummy object is returned: Once model() has been returned, the renderComponent() method call ItemDisplayComponent model.
  • 24. Not only push data paths. They can also receive actions. Actions are sent from components or other routes, so that the logic transitions involving URL or another route-level issue. Routing
  • 25. Routing What’s going on here? 1. The Router parses the /items/2 URL and dispatches control to a matching route: ItemRoute with a parameter item_id=2 2. ItemRoute invokes its model() hook, in which our app returns a model (Item with id=2) fetched via a service 3. renderComponent() is then run to render the component ItemDisplayComponent, passing it the resolved model Item 4. ItemDisplayComponent is responsible for the user interface: rendering/updating the DOM, and handling browser events
  • 26. The application route is entered when your app first boots up. Like other routes, it will load a template with the same name (application in this case) by default. You should put your header, footer, and any other decorative content here. All other routes will render their templates into the application.hbs template's {{outlet}}. This route is part of every application, so you don't need to specify it in your app/router.js. Routing The application route: Index Routes: At every level of nesting (including the top level), Ember automatically provides a route for the / path named index.
  • 28. app/helpers/sum.js export function sum(params) { return params.reduce((a, b) => { return a + b; }); }; export default Ember.Helper.helper(sum); Templates <p>Total: {{sum 1 2 3}}</p> {{sum (multiply 2 4) 2}}
  • 29. <div> {{if isFast "I am fast" "I am slow"}} </div> Templates <div> {{if isFast (if isFueled "zoooom")}} </div> {{#if isAtWork}} Ship that code! {{else if isReading}} You can finish War and Peace eventually... {{/if}}
  • 30. {{#each people as |person|}} Hello, {{person.name}}! {{else}} Sorry, nobody is here. {{/each}} Templates <ul> {{#each people as |person index|}} <li>Hello, {{person.name}}! You're number {{index}} in line</li> {{/each}} </ul>
  • 31. /app/components/store-categories.js export default Ember.Component.extend({ willRender() { this.set('categories', { 'Bourbons': ['Bulleit', 'Four Roses', 'Woodford Reserve'], 'Ryes': ['WhistlePig', 'High West'] }); } }); Templates /app/templates/components/store-categories.hbs <ul> {{#each-in categories as |category products|}} <li>{{category}} <ol> {{#each products as |product|}} <li>{{product}}</li> {{/each}} </ol> </li> {{/each-in}} </ul> <ul> <li>Bourbons <ol> <li>Bulleit</li> <li>Four Roses</li> <li>Woodford Reserve</li> </ol> </li> <li>Ryes <ol> <li>WhistlePig</li> <li>High West</li> </ol> </li> </ul>
  • 32. /app/components/store-categories.js export default Ember.Component.extend({ willRender() { this.set('categories', { 'Bourbons': ['Bulleit', 'Four Roses', 'Woodford Reserve'], 'Ryes': ['WhistlePig', 'High West'] }); }, actions: { addCategory(category) { let categories = this.get('categories'); categories[category] = [ ]; // A manual re-render causes the DOM to be updated this.rerender(); } } }); Templates
  • 33. app/templates/components/single-post.hbs <p><button {{action "select" post}}>✓</button> {{post.title}}</p> Templates app/components/single-post.js export default Ember.Component.extend({ actions: { select(post) { console.log(post.get('title')); } } }); app/templates/components/single-post.hbs <p> <button {{action "select" post on="mouseUp"}}>✓</button> {{post.title}} </p>
  • 35. ember generate component my-component-name installing component create app/components/my-component-name.js create app/templates/components/my-component-name.hbs installing component-test create tests/integration/components/my-component-name-test.js Components app/templates/components/blog-post.hbs <article class="blog-post"> <h1>{{title}}</h1> <p>{{yield}}</p> <p>Edit title: {{input type="text" value=title}}</p> </article> app/templates/index.hbs {{#each model as |post|}} {{#blog-post title=post.title}} {{post.body}} {{/blog-post}} {{/each}} app/routes/index.js export default Ember.Route.extend({ model() { return this.store.findAll('post'); } }); https://ember-twiddle.com/7ff20a68a367df12a894294d837bc391?openFiles=controllers.application.js%2Cblog-post.template. hbs
  • 37. A controller is a routable object meant to “decorate” a model with display logic. Controllers
  • 38. A controller is a routable object meant to “decorate” a model with display logic. Controllers
  • 40. Mirage Ember CLI Mirage is a client side mock server to develop and prototype applications. Fixtures and Factories We now have a couple of choices. We can create data using fixtures, or generate them through a factory. It's probably a good idea to use factories. They can easily be added to your tests.
  • 42. More information in... ● https://guides.emberjs.com/v2.4.0/ ● http://emberjs.com/api/ ● https://ember-twiddle.com/ ● http://emberigniter.com/ ● http://yoember.com/