SlideShare a Scribd company logo
1 of 29
INTRO TO
EMBER.JSSandino Núñez
@sandinosaso
https://github.com/sandinosaso
YES, ANOTHER JAVASCRIPT
FRAMEWORK
EMBER.JS
WHAT IS
EMBER.JS
➤ A framework for creating ambitious web application
➤ Built for productivity (provides architecture)
➤ Opinionated (sometimes perceived as difficult to learn)
➤ Convention over Configuration
(besides awesome!)
EMBER IN
THE WILD
http://emberjs.com/ember-users/
Simple apps can use
simple tools
APPS
NEEDS
➤ Keep it organized
➤ Modularize your code
➤ Separate concerns
➤ Establish conventions for smooth
teamwork
➤ Keep it testable
ARCHITECTUREBIG
EMBER CORE
CONCEPTS
➤ Classes and Instances
➤ Computed Properties
➤ Bindings
➤ Templates
➤ Route
➤ Models
➤ Components
➤ Data Down - Actions Up
➤ Lots of other features - we’ll just barely scratch the surface in
today’s session
EMBER
OBJECT➤ Base “class” that almost every object should inherit from
➤ Contains …
EMBER
OBJECT1 import Ember from 'ember';
2
3 let Person = Ember.Object.extend({
4 say(message) {
5 alert(message);
6 }
7 });
8
9 let Bob = Person.create();
10 Bob.say('Hello World');
11 // alerts "Hello World"
12
13 let Man = Person.extend({
14 say(message) {
15 message += ', says the man.';
16 this._super(message);
17 }
18 });
19
20 let Tom = Man.create();
21 Tom.say('Hello World');
EMBER
OBJECT
➤ Obj.create() instead of new instances
➤ Obj.extend() for single inheritance (mixins exists as well)
➤ this._super() calls overridden implementation
➤ Obj.reopen() to edit class definition
➤ Obj.get(‘key’) and Obj.set(‘key’)
➤ Allows dynamically created property values
➤ Object can listen for properties changes
➤ Use of .setProperties({ key: value }) for multiple at time.
COMPUTED
PROPERTIES➤ Used to build a property that depends on other properties
➤ Provide any property key you access and the property value
will be recomputed if change
➤ Should not contain application behavior, and should generally
not cause any side-effects when called.
1 import Ember from 'ember';
2
3 let Person = Ember.Object.extend({
4 firstName: '',
5 lastName: '',
6
7 fullName: Ember.computed('firstName', 'lastName', function() {
8 return this.get('firstName') + ' ' + this.get('lastName');
9 })
10 });
11
12 let bob = Person.create({
13 firstName: 'Bob',
14 lastName: 'Esponja'
15 });
16
17 bob.get('fullName');
18 // "Bob Esponja"
COMPUTED
PROPERTIES
(advanced usage)
1 export default Ember.Component.extend({
2 selectedTodo: null,
3
4 todos: [
5 Ember.Object.create({ isDone: true }),
6 Ember.Object.create({ isDone: false }),
7 Ember.Object.create({ isDone: true })
8 ],
9
10 // Custom
11 incomplete: Ember.computed('todos.@each.isDone', function() {
12 var todos = this.get('todos');
13 return todos.filterBy('isDone', false);
14 }),
15
16 // Using defined macro
17 incomplete: Ember.computed.filterBy('todos', 'isDone', false),
18
19 indexOfSelectedTodo: Ember.computed('selectedTodo', 'todos.[]', function() {
20 return this.get('todos').indexOf(this.get('selectedTodo'));
21 })
22 });
BINDINGS
➤ Unlike most other frameworks that include some sort of binding
implementation, bindings in Ember can be used with any object.
➤ A one-way binding only propagates changes in one direction, using
computed.oneWay()
1 wife = Ember.Object.create({
2 householdIncome: 80000
3 });
4
5 Husband = Ember.Object.extend({
6 householdIncome: Ember.computed.alias('wife.householdIncome')
7 });
8
9 husband = Husband.create({
10 wife: wife
11 });
12
13 husband.get('householdIncome'); // 80000
14
15 // Someone gets raise.
16 wife.set('householdIncome', 90000);
17 husband.get('householdIncome'); // 90000
TEMPLATES
➤ Uses Handlebars + Ember helpers
➤ Ember adds partial, render, view and control helpers
➤ Each template is backed by a model
➤ They include helpers such as: other templates, if else, loops,
formatting helpers, expressions like {{model.firstName}},
outlets (which are placeholders), components
1 <div id="main">
2 <div class="container-fluid">
3
4 {{outlet}}
5
6 </div>
7 </div>
ROUTES
➤ Url representation of your application’s objects, telling the template
➤ The router.js file defines the mapping between routes/urls
1 import Ember from 'ember';
2 import config from './config/environment';
3
4 const Router = Ember.Router.extend({
5 location: config.locationType
6 });
7
8 Router.map(function() {
9 this.route('login');
10
11 this.route('patients', function() {
12 this.route('new');
13 this.route('edit', { path: 'edit/:id' });
14 this.route('view', { path: 'view/:id' });
15 this.route('audit', { path: 'audit/:id' });
16
17 this.route('activities', { path: '/activities/:patient_id' }, function() {
18 this.route('new', { path: 'new' });
19 this.route('view', { path: 'view/:id' });
20 });
21
22 this.route('events', { path: '/events/:patient_id' }, function() {
23 this.route('new', { path: '/new/:eventType' });
24 this.route('view', { path: '/view/:id' });
25 });
26
27 });
28 });
29
30 export default Router;
1 import Ember from 'ember';
2
3 export default Ember.route.extend({
4
5 model: function() {
6 return [
7 {
8 title: “London Palace"
9 },
10 {
11 title: "Eiffel Tower"
12 }
13 ];
14 }
15 });
ROUTING(implementation of a base route)
The model usually is a
record. The result of a query
to ember-data store
1 import Ember from 'ember';
2
3 export default Ember.route.extend({
4
5 model(params) {
6 var url = 'https://api.github.com/repos/' + params.repo_id;
7 return Ember.$.getJSON(url);
8 }
9 });
The model can be a POJO
1 import Ember from 'ember';
2
3 export default Ember.route.extend({
4
5 model: function(params) {
6 return this.store.find('myModel', params);
7 },
8
9 setupController: function(controller, model) {
10 controller.set('model', model);
11 }
12 });
The result of an ajax call
ROUTING(returning multiple models)
1 import Ember from 'ember';
2
3 export default Ember.route.extend({
4
5 setupController(controller, model) {
6 controller.setProperties({
7 patient: model.patient,
8 products: model.products
9 });
10
11 set(controller, 'isLoading', false);
12 },
13
14 model(params) {
15 return RSVP.hash({
16 patient: this.store.findRecord('patient', params.id),
17 products: this.store.findAll('product')
18 });
19 }
20 });
ROUTES
➤ The route queries the model and makes it available in the controller and
templates
➤ When the template or models being shown to the user changes, Ember
automatically keeps the url in the browser’s address bar up-to-date
➤ This means that at any point, users are able to share the URL of your app
➤ Ember Add-on for Chrome and Firefox let you inspect routes / data / promises
➤ error and loading routes automatically created and used on model loading and
error states
MODELS
➤ Define a mapping to the application data
➤ Has default types: string, number, boolean, date. Supports customs types
1 import Ember from 'ember';
2 import Model from 'ember-data/model';
3 import attr from 'ember-data/attr';
4 import { belongsTo, hasMany } from 'ember-data/relationships';
5
6 const { computed } = Ember;
7
8 export default Model.extend({
9 'name': attr('string'),
10 'surname': attr('number'),
11 'is_admin': attr('boolean'),
12
13 'roles': hasMany('roles', { embedded: 'always'}),
14 'office': belongsTo('office', { async: 'true' }),
15
16 fullName: computed('name', 'surname', () => {
17 return this.get('name') + ' ' + this.get('surname');
18 }),
19
20 roleList: computed('roles.@each', () => {
21 return this.get('roles').map((role) => {
22 return role.get('name');
23 })
24 })
25 });
MODELS
➤ In the first case the data comes from backend in the model itself (payload)
➤ In the second case the model only contains the ‘ID’ of the related model
and is loaded asynchrony with an specific call when required.
13 'roles': hasMany('roles', { embedded: 'always'}),
14 'office': belongsTo('office', { async: 'true' }),
(relationships)
You can also define custom attr options, for example (readOnly):
16 'entityId': attr('string', { readOnly: true }),
17 'entityType': attr('string', { readOnly: true }),
MODELS
➤ You can define custom types to fit any kind of data
➤ Makes it easy to maintain as you only need to change in one place
1 // app/transforms/utc.js
2 import DS from 'ember-data';
3 import moment from 'moment';
4
5 export default DS.Transform.extend({
6 serialize(value) {
7 let formatedDate = moment.utc(value).format('YYYY-MM-DDTHH:mm:ss', 'en');
8 return formatedDate;
9 },
10
11 deserialize(value) {
12 return value;
13 }
14 });
1 export default Model.extend({
2 'productId': attr('number'),
3 'eventTypeID': attr('number'),
4 'reasonSVID': attr('string'),
5 'notes': attr('string'),
6
7 'eventDate': attr('utc', { defaultValue: () => new Date() })
8 }
ADAPTER /
SERIALIZER➤ By default ember-data uses JSON-API format
➤ You can override default behavior either application level or for particular models
(fit any backend data even legacy one !!)
➤ In Ember Data, the Adapter determines how data is persisted to a
backend data store, such as the URL format and headers for a
REST API.
➤ You can change default functionality (if your backend conventions
differ from ember-data assumptions) by extending it
ADAPTER(customization example)
1 import Ember from 'ember';
2 import DS from 'ember-data';
3
4 export default DS.JSONAPIAdapter.extend({
5 host: 'https://api.example.com',
6 namespace: 'api',
7
8 session: Ember.inject.service('session'),
9
10 headers: Ember.computed('session.authToken', function() {
11 return {
12 'API_KEY': this.get('session.authToken'),
13 'ANOTHER_HEADER': 'Some header value'
14 };
15 })
16 });
➤ In Ember Data, serializers format the data sent to and
received from the backend store.
SERIALIZER(customization example)
ADAPTER /
SERIALIZER
(customization/ methods)
COMPONEN
TS➤ A completed isolated view that has no access to the surrounding context
➤ A great way to build reusable components for your application
➤ routable-components will be the future
DATA DOWN!
ACTIONS UP!➤ DDAU - single data flow (hence unidirectional)
➤ Apps easier to reason about
➤ Improves performance
(GoodBye MVC)
DEMO -
SHOWCASE - TIME

More Related Content

What's hot

Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptVisual Engineering
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todaygerbille
 
Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications Juliana Lucena
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIVisual Engineering
 
iPhone Appleless Apps
iPhone Appleless AppsiPhone Appleless Apps
iPhone Appleless AppsRemy Sharp
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJSRan Mizrahi
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkJeremy Kendall
 
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreSymfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreRyan Weaver
 
Webapps without the web
Webapps without the webWebapps without the web
Webapps without the webRemy Sharp
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIVisual Engineering
 
A New Baseline for Front-End Devs
A New Baseline for Front-End DevsA New Baseline for Front-End Devs
A New Baseline for Front-End DevsRebecca Murphey
 
A Little Backbone For Your App
A Little Backbone For Your AppA Little Backbone For Your App
A Little Backbone For Your AppLuca Mearelli
 
Using Objects to Organize your jQuery Code
Using Objects to Organize your jQuery CodeUsing Objects to Organize your jQuery Code
Using Objects to Organize your jQuery CodeRebecca Murphey
 
To Batch Or Not To Batch
To Batch Or Not To BatchTo Batch Or Not To Batch
To Batch Or Not To BatchLuca Mearelli
 
Controlling The Cloud With Python
Controlling The Cloud With PythonControlling The Cloud With Python
Controlling The Cloud With PythonLuca Mearelli
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.jsBert Wijnants
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS DirectivesEyal Vardi
 

What's hot (20)

Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of today
 
Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte II
 
iPhone Appleless Apps
iPhone Appleless AppsiPhone Appleless Apps
iPhone Appleless Apps
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJS
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
 
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreSymfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
 
Webapps without the web
Webapps without the webWebapps without the web
Webapps without the web
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte III
 
A New Baseline for Front-End Devs
A New Baseline for Front-End DevsA New Baseline for Front-End Devs
A New Baseline for Front-End Devs
 
A Little Backbone For Your App
A Little Backbone For Your AppA Little Backbone For Your App
A Little Backbone For Your App
 
Modular and Event-Driven JavaScript
Modular and Event-Driven JavaScriptModular and Event-Driven JavaScript
Modular and Event-Driven JavaScript
 
Using Objects to Organize your jQuery Code
Using Objects to Organize your jQuery CodeUsing Objects to Organize your jQuery Code
Using Objects to Organize your jQuery Code
 
To Batch Or Not To Batch
To Batch Or Not To BatchTo Batch Or Not To Batch
To Batch Or Not To Batch
 
Controlling The Cloud With Python
Controlling The Cloud With PythonControlling The Cloud With Python
Controlling The Cloud With Python
 
Boost your angular app with web workers
Boost your angular app with web workersBoost your angular app with web workers
Boost your angular app with web workers
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.js
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS Directives
 
jQuery: Events, Animation, Ajax
jQuery: Events, Animation, AjaxjQuery: Events, Animation, Ajax
jQuery: Events, Animation, Ajax
 

Viewers also liked

Brief Introduction to Ember
Brief Introduction to EmberBrief Introduction to Ember
Brief Introduction to EmberVinay B
 
Ember Reusable Components and Widgets
Ember Reusable Components and WidgetsEmber Reusable Components and Widgets
Ember Reusable Components and WidgetsSergey Bolshchikov
 
Introduction to Ember.js
Introduction to Ember.jsIntroduction to Ember.js
Introduction to Ember.jsJeremy Brown
 
From 0 to Ember
From 0 to EmberFrom 0 to Ember
From 0 to EmberTracy Lee
 
Ember Data Introduction and Basic Concepts
Ember Data Introduction and Basic ConceptsEmber Data Introduction and Basic Concepts
Ember Data Introduction and Basic ConceptsAdam Kloboučník
 
AfriGadget @ Webmontag Frankfurt, June 6, 2011
AfriGadget @ Webmontag Frankfurt, June 6, 2011AfriGadget @ Webmontag Frankfurt, June 6, 2011
AfriGadget @ Webmontag Frankfurt, June 6, 2011Juergen Eichholz
 
The Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cliThe Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cliTracy Lee
 
What I learned in my First 9 months of Ember
What I learned in my First 9 months of EmberWhat I learned in my First 9 months of Ember
What I learned in my First 9 months of EmberSara Raasch
 
electron for emberists
electron for emberistselectron for emberists
electron for emberistsAidan Nulman
 
Velocity spa faster_092116
Velocity spa faster_092116Velocity spa faster_092116
Velocity spa faster_092116Manuel Alvarez
 
20120518 mssql table_schema_xml_namespace
20120518 mssql table_schema_xml_namespace20120518 mssql table_schema_xml_namespace
20120518 mssql table_schema_xml_namespaceLearningTech
 
Testing ember data transforms
Testing ember data transformsTesting ember data transforms
Testing ember data transformsSara Raasch
 

Viewers also liked (20)

Brief Introduction to Ember
Brief Introduction to EmberBrief Introduction to Ember
Brief Introduction to Ember
 
Ember Reusable Components and Widgets
Ember Reusable Components and WidgetsEmber Reusable Components and Widgets
Ember Reusable Components and Widgets
 
Introduction to Ember.js
Introduction to Ember.jsIntroduction to Ember.js
Introduction to Ember.js
 
EmberJS
EmberJSEmberJS
EmberJS
 
Demi-PDF
Demi-PDFDemi-PDF
Demi-PDF
 
From 0 to Ember
From 0 to EmberFrom 0 to Ember
From 0 to Ember
 
Attribute actions
Attribute actionsAttribute actions
Attribute actions
 
Ember Data Introduction and Basic Concepts
Ember Data Introduction and Basic ConceptsEmber Data Introduction and Basic Concepts
Ember Data Introduction and Basic Concepts
 
Ember Data
Ember DataEmber Data
Ember Data
 
Agile Point
Agile PointAgile Point
Agile Point
 
AfriGadget @ Webmontag Frankfurt, June 6, 2011
AfriGadget @ Webmontag Frankfurt, June 6, 2011AfriGadget @ Webmontag Frankfurt, June 6, 2011
AfriGadget @ Webmontag Frankfurt, June 6, 2011
 
The Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cliThe Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cli
 
Ajax Ppt 1
Ajax Ppt 1Ajax Ppt 1
Ajax Ppt 1
 
What I learned in my First 9 months of Ember
What I learned in my First 9 months of EmberWhat I learned in my First 9 months of Ember
What I learned in my First 9 months of Ember
 
electron for emberists
electron for emberistselectron for emberists
electron for emberists
 
Velocity spa faster_092116
Velocity spa faster_092116Velocity spa faster_092116
Velocity spa faster_092116
 
Masa Israel Programs Overview
Masa Israel Programs OverviewMasa Israel Programs Overview
Masa Israel Programs Overview
 
Delivering with ember.js
Delivering with ember.jsDelivering with ember.js
Delivering with ember.js
 
20120518 mssql table_schema_xml_namespace
20120518 mssql table_schema_xml_namespace20120518 mssql table_schema_xml_namespace
20120518 mssql table_schema_xml_namespace
 
Testing ember data transforms
Testing ember data transformsTesting ember data transforms
Testing ember data transforms
 

Similar to Intro to Ember.JS 2016

Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013Laurent_VB
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot CampTroy Miles
 
Sencha Touch - Introduction
Sencha Touch - IntroductionSencha Touch - Introduction
Sencha Touch - IntroductionABC-GROEP.BE
 
前端MVC 豆瓣说
前端MVC 豆瓣说前端MVC 豆瓣说
前端MVC 豆瓣说Ting Lv
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Davide Cerbo
 
Non Conventional Android Programming En
Non Conventional Android Programming EnNon Conventional Android Programming En
Non Conventional Android Programming Enguest9bcef2f
 
node.js practical guide to serverside javascript
node.js practical guide to serverside javascriptnode.js practical guide to serverside javascript
node.js practical guide to serverside javascriptEldar Djafarov
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
AST Rewriting Using recast and esprima
AST Rewriting Using recast and esprimaAST Rewriting Using recast and esprima
AST Rewriting Using recast and esprimaStephen Vance
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mateCodemotion
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datosphilogb
 
The State of JavaScript (2015)
The State of JavaScript (2015)The State of JavaScript (2015)
The State of JavaScript (2015)Domenic Denicola
 
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJSJavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJSphilogb
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptIngvar Stepanyan
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaExoLeaders.com
 
Micro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMicro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMichael Dawson
 

Similar to Intro to Ember.JS 2016 (20)

Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2
 
Sencha Touch - Introduction
Sencha Touch - IntroductionSencha Touch - Introduction
Sencha Touch - Introduction
 
前端MVC 豆瓣说
前端MVC 豆瓣说前端MVC 豆瓣说
前端MVC 豆瓣说
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)
 
Non Conventional Android Programming En
Non Conventional Android Programming EnNon Conventional Android Programming En
Non Conventional Android Programming En
 
Express JS
Express JSExpress JS
Express JS
 
node.js practical guide to serverside javascript
node.js practical guide to serverside javascriptnode.js practical guide to serverside javascript
node.js practical guide to serverside javascript
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
AST Rewriting Using recast and esprima
AST Rewriting Using recast and esprimaAST Rewriting Using recast and esprima
AST Rewriting Using recast and esprima
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mate
 
Workshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte IWorkshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte I
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datos
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
The State of JavaScript (2015)
The State of JavaScript (2015)The State of JavaScript (2015)
The State of JavaScript (2015)
 
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJSJavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with Karma
 
Micro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMicro app-framework - NodeLive Boston
Micro app-framework - NodeLive Boston
 

Recently uploaded

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 

Recently uploaded (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 

Intro to Ember.JS 2016

  • 4. WHAT IS EMBER.JS ➤ A framework for creating ambitious web application ➤ Built for productivity (provides architecture) ➤ Opinionated (sometimes perceived as difficult to learn) ➤ Convention over Configuration (besides awesome!)
  • 6. Simple apps can use simple tools
  • 7. APPS NEEDS ➤ Keep it organized ➤ Modularize your code ➤ Separate concerns ➤ Establish conventions for smooth teamwork ➤ Keep it testable ARCHITECTUREBIG
  • 8. EMBER CORE CONCEPTS ➤ Classes and Instances ➤ Computed Properties ➤ Bindings ➤ Templates ➤ Route ➤ Models ➤ Components ➤ Data Down - Actions Up ➤ Lots of other features - we’ll just barely scratch the surface in today’s session
  • 9. EMBER OBJECT➤ Base “class” that almost every object should inherit from ➤ Contains …
  • 10. EMBER OBJECT1 import Ember from 'ember'; 2 3 let Person = Ember.Object.extend({ 4 say(message) { 5 alert(message); 6 } 7 }); 8 9 let Bob = Person.create(); 10 Bob.say('Hello World'); 11 // alerts "Hello World" 12 13 let Man = Person.extend({ 14 say(message) { 15 message += ', says the man.'; 16 this._super(message); 17 } 18 }); 19 20 let Tom = Man.create(); 21 Tom.say('Hello World');
  • 11. EMBER OBJECT ➤ Obj.create() instead of new instances ➤ Obj.extend() for single inheritance (mixins exists as well) ➤ this._super() calls overridden implementation ➤ Obj.reopen() to edit class definition ➤ Obj.get(‘key’) and Obj.set(‘key’) ➤ Allows dynamically created property values ➤ Object can listen for properties changes ➤ Use of .setProperties({ key: value }) for multiple at time.
  • 12. COMPUTED PROPERTIES➤ Used to build a property that depends on other properties ➤ Provide any property key you access and the property value will be recomputed if change ➤ Should not contain application behavior, and should generally not cause any side-effects when called. 1 import Ember from 'ember'; 2 3 let Person = Ember.Object.extend({ 4 firstName: '', 5 lastName: '', 6 7 fullName: Ember.computed('firstName', 'lastName', function() { 8 return this.get('firstName') + ' ' + this.get('lastName'); 9 }) 10 }); 11 12 let bob = Person.create({ 13 firstName: 'Bob', 14 lastName: 'Esponja' 15 }); 16 17 bob.get('fullName'); 18 // "Bob Esponja"
  • 13. COMPUTED PROPERTIES (advanced usage) 1 export default Ember.Component.extend({ 2 selectedTodo: null, 3 4 todos: [ 5 Ember.Object.create({ isDone: true }), 6 Ember.Object.create({ isDone: false }), 7 Ember.Object.create({ isDone: true }) 8 ], 9 10 // Custom 11 incomplete: Ember.computed('todos.@each.isDone', function() { 12 var todos = this.get('todos'); 13 return todos.filterBy('isDone', false); 14 }), 15 16 // Using defined macro 17 incomplete: Ember.computed.filterBy('todos', 'isDone', false), 18 19 indexOfSelectedTodo: Ember.computed('selectedTodo', 'todos.[]', function() { 20 return this.get('todos').indexOf(this.get('selectedTodo')); 21 }) 22 });
  • 14. BINDINGS ➤ Unlike most other frameworks that include some sort of binding implementation, bindings in Ember can be used with any object. ➤ A one-way binding only propagates changes in one direction, using computed.oneWay() 1 wife = Ember.Object.create({ 2 householdIncome: 80000 3 }); 4 5 Husband = Ember.Object.extend({ 6 householdIncome: Ember.computed.alias('wife.householdIncome') 7 }); 8 9 husband = Husband.create({ 10 wife: wife 11 }); 12 13 husband.get('householdIncome'); // 80000 14 15 // Someone gets raise. 16 wife.set('householdIncome', 90000); 17 husband.get('householdIncome'); // 90000
  • 15. TEMPLATES ➤ Uses Handlebars + Ember helpers ➤ Ember adds partial, render, view and control helpers ➤ Each template is backed by a model ➤ They include helpers such as: other templates, if else, loops, formatting helpers, expressions like {{model.firstName}}, outlets (which are placeholders), components 1 <div id="main"> 2 <div class="container-fluid"> 3 4 {{outlet}} 5 6 </div> 7 </div>
  • 16. ROUTES ➤ Url representation of your application’s objects, telling the template ➤ The router.js file defines the mapping between routes/urls 1 import Ember from 'ember'; 2 import config from './config/environment'; 3 4 const Router = Ember.Router.extend({ 5 location: config.locationType 6 }); 7 8 Router.map(function() { 9 this.route('login'); 10 11 this.route('patients', function() { 12 this.route('new'); 13 this.route('edit', { path: 'edit/:id' }); 14 this.route('view', { path: 'view/:id' }); 15 this.route('audit', { path: 'audit/:id' }); 16 17 this.route('activities', { path: '/activities/:patient_id' }, function() { 18 this.route('new', { path: 'new' }); 19 this.route('view', { path: 'view/:id' }); 20 }); 21 22 this.route('events', { path: '/events/:patient_id' }, function() { 23 this.route('new', { path: '/new/:eventType' }); 24 this.route('view', { path: '/view/:id' }); 25 }); 26 27 }); 28 }); 29 30 export default Router;
  • 17. 1 import Ember from 'ember'; 2 3 export default Ember.route.extend({ 4 5 model: function() { 6 return [ 7 { 8 title: “London Palace" 9 }, 10 { 11 title: "Eiffel Tower" 12 } 13 ]; 14 } 15 }); ROUTING(implementation of a base route) The model usually is a record. The result of a query to ember-data store 1 import Ember from 'ember'; 2 3 export default Ember.route.extend({ 4 5 model(params) { 6 var url = 'https://api.github.com/repos/' + params.repo_id; 7 return Ember.$.getJSON(url); 8 } 9 }); The model can be a POJO 1 import Ember from 'ember'; 2 3 export default Ember.route.extend({ 4 5 model: function(params) { 6 return this.store.find('myModel', params); 7 }, 8 9 setupController: function(controller, model) { 10 controller.set('model', model); 11 } 12 }); The result of an ajax call
  • 18. ROUTING(returning multiple models) 1 import Ember from 'ember'; 2 3 export default Ember.route.extend({ 4 5 setupController(controller, model) { 6 controller.setProperties({ 7 patient: model.patient, 8 products: model.products 9 }); 10 11 set(controller, 'isLoading', false); 12 }, 13 14 model(params) { 15 return RSVP.hash({ 16 patient: this.store.findRecord('patient', params.id), 17 products: this.store.findAll('product') 18 }); 19 } 20 });
  • 19. ROUTES ➤ The route queries the model and makes it available in the controller and templates ➤ When the template or models being shown to the user changes, Ember automatically keeps the url in the browser’s address bar up-to-date ➤ This means that at any point, users are able to share the URL of your app ➤ Ember Add-on for Chrome and Firefox let you inspect routes / data / promises ➤ error and loading routes automatically created and used on model loading and error states
  • 20. MODELS ➤ Define a mapping to the application data ➤ Has default types: string, number, boolean, date. Supports customs types 1 import Ember from 'ember'; 2 import Model from 'ember-data/model'; 3 import attr from 'ember-data/attr'; 4 import { belongsTo, hasMany } from 'ember-data/relationships'; 5 6 const { computed } = Ember; 7 8 export default Model.extend({ 9 'name': attr('string'), 10 'surname': attr('number'), 11 'is_admin': attr('boolean'), 12 13 'roles': hasMany('roles', { embedded: 'always'}), 14 'office': belongsTo('office', { async: 'true' }), 15 16 fullName: computed('name', 'surname', () => { 17 return this.get('name') + ' ' + this.get('surname'); 18 }), 19 20 roleList: computed('roles.@each', () => { 21 return this.get('roles').map((role) => { 22 return role.get('name'); 23 }) 24 }) 25 });
  • 21. MODELS ➤ In the first case the data comes from backend in the model itself (payload) ➤ In the second case the model only contains the ‘ID’ of the related model and is loaded asynchrony with an specific call when required. 13 'roles': hasMany('roles', { embedded: 'always'}), 14 'office': belongsTo('office', { async: 'true' }), (relationships) You can also define custom attr options, for example (readOnly): 16 'entityId': attr('string', { readOnly: true }), 17 'entityType': attr('string', { readOnly: true }),
  • 22. MODELS ➤ You can define custom types to fit any kind of data ➤ Makes it easy to maintain as you only need to change in one place 1 // app/transforms/utc.js 2 import DS from 'ember-data'; 3 import moment from 'moment'; 4 5 export default DS.Transform.extend({ 6 serialize(value) { 7 let formatedDate = moment.utc(value).format('YYYY-MM-DDTHH:mm:ss', 'en'); 8 return formatedDate; 9 }, 10 11 deserialize(value) { 12 return value; 13 } 14 }); 1 export default Model.extend({ 2 'productId': attr('number'), 3 'eventTypeID': attr('number'), 4 'reasonSVID': attr('string'), 5 'notes': attr('string'), 6 7 'eventDate': attr('utc', { defaultValue: () => new Date() }) 8 }
  • 23. ADAPTER / SERIALIZER➤ By default ember-data uses JSON-API format ➤ You can override default behavior either application level or for particular models (fit any backend data even legacy one !!)
  • 24. ➤ In Ember Data, the Adapter determines how data is persisted to a backend data store, such as the URL format and headers for a REST API. ➤ You can change default functionality (if your backend conventions differ from ember-data assumptions) by extending it ADAPTER(customization example) 1 import Ember from 'ember'; 2 import DS from 'ember-data'; 3 4 export default DS.JSONAPIAdapter.extend({ 5 host: 'https://api.example.com', 6 namespace: 'api', 7 8 session: Ember.inject.service('session'), 9 10 headers: Ember.computed('session.authToken', function() { 11 return { 12 'API_KEY': this.get('session.authToken'), 13 'ANOTHER_HEADER': 'Some header value' 14 }; 15 }) 16 });
  • 25. ➤ In Ember Data, serializers format the data sent to and received from the backend store. SERIALIZER(customization example)
  • 27. COMPONEN TS➤ A completed isolated view that has no access to the surrounding context ➤ A great way to build reusable components for your application ➤ routable-components will be the future
  • 28. DATA DOWN! ACTIONS UP!➤ DDAU - single data flow (hence unidirectional) ➤ Apps easier to reason about ➤ Improves performance (GoodBye MVC)

Editor's Notes

  1. Yes, this talk is about another Javascript framework but before you say Ohh I like Angular, React or other just remember that each year trends changes so why not give Ember a try? If you see I intentionally left Ember out this slide image, maybe 2016 or 2017 may be the Ember year
  2. Mention Yehudi Katz, Core Team Member at Ruby and JQuery. He brings best ideas of both world. There is no corporation around this framework. Only a small community. I have found that very good developers are part of this community. So maybe this talk is an invitation to join.
  3. If a framework is opinionated, it lock or guides you into their way of doing things. Convention over configuration (also known as coding by convention) is a software design paradigm used by software frameworks that attempt to decrease the number of decisions that a developer using the framework is required to make without necessarily losing flexibility. The concept was introduced by David Heinemeier Hansson to describe the philosophy of the Ruby on Rails web framework.
  4. Not so sure about this affirmation, even small apps may get benefits from using a framework
  5. Architecture means you make code that keep organized, you use stablished conventions and keep it testable and maintainable
  6. Here, the dependent key todos.@each.isDone instructs Ember.js to update bindings and fire observers when any of the following events occurs: The isDone property of any of the object of the array changes An item is added/removed from the todos array todos property changes to a different array Sometimes you don't care if properties of individual array items change. In this case use the [] key instead of @each. Computed properties dependent on an array using the [] key will only update if items are added to or removed from the array, or if the array property is set to a different array. Here, indexOfSelectedTodo depends on todos.[], so it will update if we add an item to todos, but won't update if the value of isDone on a todo changes
  7. Because Ember supports promises, it can work with any persistence library that uses them as part of its public API. You can also use many of the conveniences built in to promises to make your code even nicer.
  8. Multiple models can be returned through an Ember.RSVP.hash. The Ember.RSVP.hash takes parameters that return promises, and when all parameter promises resolve, then the Ember.RSVP.hash promise resolves
  9. When accessing patients.edit route then Ember will search for: patients.edit-loading patients.loading or patients_loading loading or application-loading If the various beforeModel/model/afterModel hooks don't immediately resolve, a loading event will be fired on that route. If the loading handler is not defined at the specific route, the event will continue to bubble above a transition's parent route, providing the application route the opportunity to manage it. When using the loading handler, we can make use of the transition promise to know when the loading event is over:
  10. Because everything in ember extends from Ember.Object we can have computed properties even in models You can define your customs types like: UTC, defining the files inside transforms/utc.js
  11. As far as I know, when async is false Ember will fetch the related entity at the same time as fetching the parent entity. When async is true, it will fetch the related entities when you actually request them. but if the relationship was stuff: DS.hasMany('stuff', {async: true}) then Ember Data is just expecting this: { user: { id: 1, stuff_id: [1, 2, 3] } } ...and if you load the user and ask for user.get('stuff') then it will make a separate request for its related Stuff objects. So it may be more helpful to think of the async: value not as telling Ember Data how to fetch things, but as telling Ember Data how to expect things from the server.
  12. You can define your customs types like: UTC, defining the files inside transforms/utc.js
  13. DS.Adapter is the basic adapter with no functionality. It is generally a good starting point if you want to create an adapter that is radically different from the other Ember adapters. DS.JSONAPIAdapter The JSONAPIAdapter is the default adapter and follows JSON API conventions to communicate with an HTTP server by transmitting JSON via XHR. DS.RESTAdapter The RESTAdapter allows your store to communicate with an HTTP server by transmitting JSON via XHR. Before Ember Data 2.0 this adapter was the default.
  14. By default the adapter will target the current domain. If you would like to specify a new domain you can do so by setting the host property on the adapter. The namespace property can be used to prefix requests with a specific url namespace.
  15. There are two ways to define a custom serializer. First, you can define a custom serializer for your entire application by defining an "application" serializer. normalizeResponse(store, primaryModelClass, payload, id, requestType) export default DS.JSONAPISerializer.extend({ primaryKey: '_id' }); keyForAttribute: function(attr) { return Ember.String.underscore(attr); } The JSONSerializer is a serializer that ships with Ember Data that can be used along side the RESTAdapter to serialize these simpler APIs.
  16. It is no secret that many new Ember 2 conventions and changes have direct influence from React and Flux (a pattern for data flow in React apps). What Flux calls the “unidirectional data flow” is what we call “Data down, actions up” (DDAU) in Ember. DDAU avoids the traditional client-side MVC pattern in favor of a single flow of data (hence unidirectional), which makes apps easier to reason about, and improves their performance. The fundamental problem with MVC is revealed as your application grows larger and more complex — cascading updates and implicit dependencies lead to a tangled mess and unpredictability. Updating one object leads to another changing, which in turn triggers more changes, and ultimately makes maintaining your application a frustrating experience.