SlideShare a Scribd company logo
EmberJS
BucharestJS
Singalong!
• https://github.com/rusanu/webstore-demo
npm install ember-cli
• The client side framework
• Routing, bidirectional data flow, Observables, Templating engine
• Data management: data store, change tracking, REST adapter, XHR/Ajax, Promises/RSVP
• Dependency injection, services, computed properties
• JS enhancements (ECMA transpiler, EM.Array to make observable arrays etc)
• The server side build
• Build, serve with live update, test, deploy
• Transpile, concat, uglify, source map, jslint
• Blueprints
• Generate model/route/component etc, including tests
• Add-on management
• Is great for starting new projects, no pick and choose, everything is ‘ready’
• Difficult to add EmberJS incrementaly on existing projects
ember new webstore-demo
• Blueprint for an empty app
• Layout page is app/index.html
• Will render the implicit ‘index’ root
route/template
• Create explicit route:
>ember generate route index
• Edit app/templates/index.hbs
• Build, Test, Serve
• Test requires PhantomJS
+---app
| +---components
| +---controllers
| +---helpers
| +---models
| +---routes
| +---styles
| ---templates
| ---components
+---config
+---public
+---tests
| +---helpers
| +---integration
| ---unit
---vendor
ember generate route index
• Routes are mapped to URLs in app/router.js
• index route is for ‘/’ at every level
• app/routes/index.js -> /
• app/routes/sprockets/index.js -> /sprockets/
• Convention app/router.js can declare whatever it pleases
• Dynamic segments: /posts/:post_id
• Implicit Application route: app/routes/application.js
• Implicit app/templates/application.hbs
• {{outlet}} yields the content of the inner template
Ember Inspector
• Chrome extension, add the Ember panel to dev tools
• You can see application, even empty, has default generated
view/controller for the root index route
ember generate model product …
• EmberJS comes with ember-data
• Data store
• Fetches data from sources (back-end)
• Tracks record changes
• Applies changes to back end
• Relashioships: belongsTo, hasMany
• Adapters to negotiate communication back end
• Typically use one of the REST adapters
• Works easiest with JSONApi.org format
• Handles the AJAX part, Promises etc
ember install ember-localstorage-adapter
• Adapters do not necessarily fetch/pull data to a back-end
• Localstorage adapter uses persistent browser Web Storage API
• You can go a long mile front-end side w/o a back-end
• You can use specific adapters for specific model types
• Convention: model named Foo uses adapter named Foo
• Fallback to Application adapter
Routes -> model -> template
• The route model() function returns the model to be rendered
• In app/routes/index.js
model() { return this.store.findAll(‘product’);}
• The store uses the adapter to retrieve all Products
• REST Adapter: GET /products
• Use the inspector, can see that the model is now an Ember.ArrayProxy
content:[]
store:<webstore-demo@service:store::ember394>
isLoaded:true
manager:<(unknown mixin):ember540>
isUpdating:false
Add a product: events and actions
• <button {{action 'addProduct'}}>Add Product</button>
• The addProduct action can be handled by components, controllers, routes
• Add a route to display/handle new product
• ember generate route products/add
• Modify app/routes/index.js to respond to the action:
actions: {
addProduct() {
this.transitionTo('products.add');
}
}
• app/routes/products/add.js
• model() { return this.store.createRecord(‘product’); }
Detour: Style it
ember install ember-cli-sass
ember install ember-cli-bootstrap-sassy
• Rename app/style/app.css to app/style/app.scss and edit it:
@import “bootstrap”;
• There is also ember-paper add-on for Material Design
aficionados
• Will have to do a full build and restart the live reload server
The add product form
• We need to get the DOM #id for labels:
http://stackoverflow.com/a/34664559/105929
• ember generate helper guid-for
• Helpers extend the templating language:
<label for="{{guid-for this "name"}}">
{{input id=(guid-for this "name") value=model.name }}
• Binding to model.name is bidirectional
• We add two buttons and bind them to add and cancel actions
Handle the save and cancel actions
• In app/routes/products/add.js
actions: {
add() {
this.modelFor(this.routeName).save().then(function() {
this.transitionTo('index');
}.bind(this));
},
cancel() {
this.modelFor(this.routeName).rollbackAttributes();
this.transitionTo('index');
}
}
• Notice the bind(this) (ECMA6) and the use of the promise when save to the back end
• this.modelFor(this.routeName) is the usual trick to access model from the route
• BTW Ember Inspector Data will not properly reflect the removal of the product on cancel
ember generate component product-panel
• In app/templates/index.hbs:
{{#each model as |product|}}
{{product-panel product=product}}
{{/each}}
• app/components/product-panel.js
• Components can add behavior, respond to actions
• EmberJS will remove controllers and use routable components instead
• App/templates/components/product-panel.hbs
• A component becomes automatically also a template helper
ember generate service shopping-cart
• EmberJS supports dependency injections, factories, singletons,
initializers and other ‘application concerns’
• A common pattern is service injection: make a ‘service’ easily
available from any part of the application
• In out product-panel.js:
shoppingCart: Ember.inject.service(),
• Makes the shopping cart available w/o having to pass parameters or
reference global
ember test
• Because we’ve been using ember generate blueprints we actually
have a test for every route, model, component, controller, serializer,
adapter helper etc.
• Blueprint tests are basic, but they do exercise the relevant code and
are the starting point for further validations and assertions.
EmberJS
• It fits best with teams, because it enforces a consistent structure
• ember-cli offers blueprints, build, serve, compile
• Because it tries to cover everything, it integrates poorly with other
frameworks
• Excelent documentation and guides at emberjs.com
• Take any EmberJS answer you find on StackOverflow pre 2015 with a
big grain of salt. Anything that predates ember-cli is likely obsolete.
• Handlebar templates are just a tiny part of EmberJS.

More Related Content

What's hot

Ruby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter BootstrapRuby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter Bootstrap
Marcio Marinho
 
Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2
Yakov Fain
 
Rails Engine | Modular application
Rails Engine | Modular applicationRails Engine | Modular application
Rails Engine | Modular application
mirrec
 
Reacting to the Isomorphic Buzz
Reacting to the Isomorphic BuzzReacting to the Isomorphic Buzz
Reacting to the Isomorphic Buzz
Bruce Coddington
 
Angular js
Angular jsAngular js
Using Angular with Rails
Using Angular with RailsUsing Angular with Rails
Using Angular with Rails
Jamie Davidson
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJS
RajthilakMCA
 
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Frost
 
How angularjs saves rails
How angularjs saves railsHow angularjs saves rails
How angularjs saves rails
Michael He
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp Atlanta
Jason Noble
 
AngularJS meets Rails
AngularJS meets RailsAngularJS meets Rails
AngularJS meets Rails
Elena Torró
 
Cocoa on-rails-3rd
Cocoa on-rails-3rdCocoa on-rails-3rd
Cocoa on-rails-3rd
Xiaochun Shen
 
Angular js
Angular jsAngular js
Angular js
yogi_solanki
 
Angular js
Angular jsAngular js
Angular js
Hritesh Saha
 
Catalog display
Catalog displayCatalog display
Catalog display
Jason Noble
 
Ember.js: Jump Start
Ember.js: Jump Start Ember.js: Jump Start
Ember.js: Jump Start
Viacheslav Bukach
 
Plugins unplugged
Plugins unpluggedPlugins unplugged
Plugins unplugged
Christian Rokitta
 
Rails engines in large apps
Rails engines in large appsRails engines in large apps
Rails engines in large apps
Enrico Teotti
 
Introduction to Ember.js
Introduction to Ember.jsIntroduction to Ember.js
Introduction to Ember.js
Jeremy Brown
 
Rails engines
Rails enginesRails engines
Rails engines
Josh Schramm
 

What's hot (20)

Ruby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter BootstrapRuby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter Bootstrap
 
Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2
 
Rails Engine | Modular application
Rails Engine | Modular applicationRails Engine | Modular application
Rails Engine | Modular application
 
Reacting to the Isomorphic Buzz
Reacting to the Isomorphic BuzzReacting to the Isomorphic Buzz
Reacting to the Isomorphic Buzz
 
Angular js
Angular jsAngular js
Angular js
 
Using Angular with Rails
Using Angular with RailsUsing Angular with Rails
Using Angular with Rails
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJS
 
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
 
How angularjs saves rails
How angularjs saves railsHow angularjs saves rails
How angularjs saves rails
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp Atlanta
 
AngularJS meets Rails
AngularJS meets RailsAngularJS meets Rails
AngularJS meets Rails
 
Cocoa on-rails-3rd
Cocoa on-rails-3rdCocoa on-rails-3rd
Cocoa on-rails-3rd
 
Angular js
Angular jsAngular js
Angular js
 
Angular js
Angular jsAngular js
Angular js
 
Catalog display
Catalog displayCatalog display
Catalog display
 
Ember.js: Jump Start
Ember.js: Jump Start Ember.js: Jump Start
Ember.js: Jump Start
 
Plugins unplugged
Plugins unpluggedPlugins unplugged
Plugins unplugged
 
Rails engines in large apps
Rails engines in large appsRails engines in large apps
Rails engines in large apps
 
Introduction to Ember.js
Introduction to Ember.jsIntroduction to Ember.js
Introduction to Ember.js
 
Rails engines
Rails enginesRails engines
Rails engines
 

Viewers also liked

The Climb: Lyrics
The Climb: LyricsThe Climb: Lyrics
The Climb: Lyrics
Viroqua
 
Pp yacht versie_def
Pp yacht versie_defPp yacht versie_def
Pp yacht versie_defLuchiena
 
2011AM1
2011AM12011AM1
Saulito in accion
Saulito in accionSaulito in accion
Saulito in accion
Roberto Arana
 
Transmedia Strategy Les 1 Minor Crossmedia Inholland Diemen
Transmedia Strategy Les 1 Minor Crossmedia Inholland DiemenTransmedia Strategy Les 1 Minor Crossmedia Inholland Diemen
Transmedia Strategy Les 1 Minor Crossmedia Inholland Diemen
Mark Jacobs
 
The art of storytelling 2014 ppt
The art of storytelling 2014 pptThe art of storytelling 2014 ppt
The art of storytelling 2014 ppt
Mark Jacobs
 
Regional strategy conference apr12
Regional strategy conference apr12Regional strategy conference apr12
Regional strategy conference apr12
Luke van der Laan
 
cuento
cuentocuento
cuento
tonal
 
คอมพิวเตอร์เบื้องต้น
คอมพิวเตอร์เบื้องต้นคอมพิวเตอร์เบื้องต้น
คอมพิวเตอร์เบื้องต้น
dusadee chooruang
 
Kata nama
Kata namaKata nama
Prudential California Realty Listing presentation
Prudential California Realty Listing presentationPrudential California Realty Listing presentation
Prudential California Realty Listing presentation
Brad Pearson
 
Industrie4.0 smart manufacturing for the future
Industrie4.0 smart manufacturing for the futureIndustrie4.0 smart manufacturing for the future
Industrie4.0 smart manufacturing for the future
Evandro MINATO
 
Journey to Recovery Part 1: Inner Healing
Journey to Recovery Part 1: Inner HealingJourney to Recovery Part 1: Inner Healing
Journey to Recovery Part 1: Inner Healing
Berean Guide
 
Kata adjektif
Kata adjektifKata adjektif
Kata adjektif
Leonard Agustinus
 
IoT in education by designing smart learning environments
IoT in education by designing smart learning environmentsIoT in education by designing smart learning environments
IoT in education by designing smart learning environments
die wissenskreateurin
 
Pantun 4 kerat
Pantun 4 keratPantun 4 kerat
Pantun 4 kerat
Leonard Agustinus
 

Viewers also liked (20)

The Climb: Lyrics
The Climb: LyricsThe Climb: Lyrics
The Climb: Lyrics
 
Pp yacht versie_def
Pp yacht versie_defPp yacht versie_def
Pp yacht versie_def
 
2011AM1
2011AM12011AM1
2011AM1
 
Saulito in accion
Saulito in accionSaulito in accion
Saulito in accion
 
Transmedia Strategy Les 1 Minor Crossmedia Inholland Diemen
Transmedia Strategy Les 1 Minor Crossmedia Inholland DiemenTransmedia Strategy Les 1 Minor Crossmedia Inholland Diemen
Transmedia Strategy Les 1 Minor Crossmedia Inholland Diemen
 
The art of storytelling 2014 ppt
The art of storytelling 2014 pptThe art of storytelling 2014 ppt
The art of storytelling 2014 ppt
 
Kata kerja
Kata kerjaKata kerja
Kata kerja
 
Regional strategy conference apr12
Regional strategy conference apr12Regional strategy conference apr12
Regional strategy conference apr12
 
cuento
cuentocuento
cuento
 
คอมพิวเตอร์เบื้องต้น
คอมพิวเตอร์เบื้องต้นคอมพิวเตอร์เบื้องต้น
คอมพิวเตอร์เบื้องต้น
 
intro computer
intro computerintro computer
intro computer
 
Kata nama
Kata namaKata nama
Kata nama
 
Presentation
PresentationPresentation
Presentation
 
Prudential California Realty Listing presentation
Prudential California Realty Listing presentationPrudential California Realty Listing presentation
Prudential California Realty Listing presentation
 
Industrie4.0 smart manufacturing for the future
Industrie4.0 smart manufacturing for the futureIndustrie4.0 smart manufacturing for the future
Industrie4.0 smart manufacturing for the future
 
Journey to Recovery Part 1: Inner Healing
Journey to Recovery Part 1: Inner HealingJourney to Recovery Part 1: Inner Healing
Journey to Recovery Part 1: Inner Healing
 
Kata adjektif
Kata adjektifKata adjektif
Kata adjektif
 
PANTUN 2 KERAT
PANTUN 2 KERATPANTUN 2 KERAT
PANTUN 2 KERAT
 
IoT in education by designing smart learning environments
IoT in education by designing smart learning environmentsIoT in education by designing smart learning environments
IoT in education by designing smart learning environments
 
Pantun 4 kerat
Pantun 4 keratPantun 4 kerat
Pantun 4 kerat
 

Similar to EmberJS BucharestJS

Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012
Dimitri de Putte
 
Ember App Kit & The Ember Resolver
Ember App Kit & The Ember ResolverEmber App Kit & The Ember Resolver
Ember App Kit & The Ember Resolver
tboyt
 
Server and client rendering of single page apps
Server and client rendering of single page appsServer and client rendering of single page apps
Server and client rendering of single page apps
Thomas Heymann
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 
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
 
Angularjs
AngularjsAngularjs
Angularjs
Ynon Perek
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
Ivano Malavolta
 
mean stack
mean stackmean stack
mean stack
michaelaaron25322
 
Client Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsClient Side MVC with Backbone and Rails
Client Side MVC with Backbone and Rails
Tom Z Zeng
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
Antônio Roberto Silva
 
Containers & Dependency in Ember.js
Containers & Dependency in Ember.jsContainers & Dependency in Ember.js
Containers & Dependency in Ember.js
Matthew Beale
 
Angular
AngularAngular
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
Troy Miles
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and server
Spike Brehm
 
Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile apps
Ivano Malavolta
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
Sapna Upreti
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
ColdFusionConference
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
Stacy London
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
Betclic Everest Group Tech Team
 
Vue js and Dyploma
Vue js and DyplomaVue js and Dyploma
Vue js and Dyploma
Yoram Kornatzky
 

Similar to EmberJS BucharestJS (20)

Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012
 
Ember App Kit & The Ember Resolver
Ember App Kit & The Ember ResolverEmber App Kit & The Ember Resolver
Ember App Kit & The Ember Resolver
 
Server and client rendering of single page apps
Server and client rendering of single page appsServer and client rendering of single page apps
Server and client rendering of single page apps
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
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...
 
Angularjs
AngularjsAngularjs
Angularjs
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
mean stack
mean stackmean stack
mean stack
 
Client Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsClient Side MVC with Backbone and Rails
Client Side MVC with Backbone and Rails
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
Containers & Dependency in Ember.js
Containers & Dependency in Ember.jsContainers & Dependency in Ember.js
Containers & Dependency in Ember.js
 
Angular
AngularAngular
Angular
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and server
 
Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile apps
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
 
Vue js and Dyploma
Vue js and DyplomaVue js and Dyploma
Vue js and Dyploma
 

Recently uploaded

Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
aymanquadri279
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 

Recently uploaded (20)

Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 

EmberJS BucharestJS

  • 3. npm install ember-cli • The client side framework • Routing, bidirectional data flow, Observables, Templating engine • Data management: data store, change tracking, REST adapter, XHR/Ajax, Promises/RSVP • Dependency injection, services, computed properties • JS enhancements (ECMA transpiler, EM.Array to make observable arrays etc) • The server side build • Build, serve with live update, test, deploy • Transpile, concat, uglify, source map, jslint • Blueprints • Generate model/route/component etc, including tests • Add-on management • Is great for starting new projects, no pick and choose, everything is ‘ready’ • Difficult to add EmberJS incrementaly on existing projects
  • 4. ember new webstore-demo • Blueprint for an empty app • Layout page is app/index.html • Will render the implicit ‘index’ root route/template • Create explicit route: >ember generate route index • Edit app/templates/index.hbs • Build, Test, Serve • Test requires PhantomJS +---app | +---components | +---controllers | +---helpers | +---models | +---routes | +---styles | ---templates | ---components +---config +---public +---tests | +---helpers | +---integration | ---unit ---vendor
  • 5. ember generate route index • Routes are mapped to URLs in app/router.js • index route is for ‘/’ at every level • app/routes/index.js -> / • app/routes/sprockets/index.js -> /sprockets/ • Convention app/router.js can declare whatever it pleases • Dynamic segments: /posts/:post_id • Implicit Application route: app/routes/application.js • Implicit app/templates/application.hbs • {{outlet}} yields the content of the inner template
  • 6. Ember Inspector • Chrome extension, add the Ember panel to dev tools • You can see application, even empty, has default generated view/controller for the root index route
  • 7. ember generate model product … • EmberJS comes with ember-data • Data store • Fetches data from sources (back-end) • Tracks record changes • Applies changes to back end • Relashioships: belongsTo, hasMany • Adapters to negotiate communication back end • Typically use one of the REST adapters • Works easiest with JSONApi.org format • Handles the AJAX part, Promises etc
  • 8. ember install ember-localstorage-adapter • Adapters do not necessarily fetch/pull data to a back-end • Localstorage adapter uses persistent browser Web Storage API • You can go a long mile front-end side w/o a back-end • You can use specific adapters for specific model types • Convention: model named Foo uses adapter named Foo • Fallback to Application adapter
  • 9. Routes -> model -> template • The route model() function returns the model to be rendered • In app/routes/index.js model() { return this.store.findAll(‘product’);} • The store uses the adapter to retrieve all Products • REST Adapter: GET /products • Use the inspector, can see that the model is now an Ember.ArrayProxy content:[] store:<webstore-demo@service:store::ember394> isLoaded:true manager:<(unknown mixin):ember540> isUpdating:false
  • 10. Add a product: events and actions • <button {{action 'addProduct'}}>Add Product</button> • The addProduct action can be handled by components, controllers, routes • Add a route to display/handle new product • ember generate route products/add • Modify app/routes/index.js to respond to the action: actions: { addProduct() { this.transitionTo('products.add'); } } • app/routes/products/add.js • model() { return this.store.createRecord(‘product’); }
  • 11. Detour: Style it ember install ember-cli-sass ember install ember-cli-bootstrap-sassy • Rename app/style/app.css to app/style/app.scss and edit it: @import “bootstrap”; • There is also ember-paper add-on for Material Design aficionados • Will have to do a full build and restart the live reload server
  • 12. The add product form • We need to get the DOM #id for labels: http://stackoverflow.com/a/34664559/105929 • ember generate helper guid-for • Helpers extend the templating language: <label for="{{guid-for this "name"}}"> {{input id=(guid-for this "name") value=model.name }} • Binding to model.name is bidirectional • We add two buttons and bind them to add and cancel actions
  • 13. Handle the save and cancel actions • In app/routes/products/add.js actions: { add() { this.modelFor(this.routeName).save().then(function() { this.transitionTo('index'); }.bind(this)); }, cancel() { this.modelFor(this.routeName).rollbackAttributes(); this.transitionTo('index'); } } • Notice the bind(this) (ECMA6) and the use of the promise when save to the back end • this.modelFor(this.routeName) is the usual trick to access model from the route • BTW Ember Inspector Data will not properly reflect the removal of the product on cancel
  • 14. ember generate component product-panel • In app/templates/index.hbs: {{#each model as |product|}} {{product-panel product=product}} {{/each}} • app/components/product-panel.js • Components can add behavior, respond to actions • EmberJS will remove controllers and use routable components instead • App/templates/components/product-panel.hbs • A component becomes automatically also a template helper
  • 15. ember generate service shopping-cart • EmberJS supports dependency injections, factories, singletons, initializers and other ‘application concerns’ • A common pattern is service injection: make a ‘service’ easily available from any part of the application • In out product-panel.js: shoppingCart: Ember.inject.service(), • Makes the shopping cart available w/o having to pass parameters or reference global
  • 16. ember test • Because we’ve been using ember generate blueprints we actually have a test for every route, model, component, controller, serializer, adapter helper etc. • Blueprint tests are basic, but they do exercise the relevant code and are the starting point for further validations and assertions.
  • 17. EmberJS • It fits best with teams, because it enforces a consistent structure • ember-cli offers blueprints, build, serve, compile • Because it tries to cover everything, it integrates poorly with other frameworks • Excelent documentation and guides at emberjs.com • Take any EmberJS answer you find on StackOverflow pre 2015 with a big grain of salt. Anything that predates ember-cli is likely obsolete. • Handlebar templates are just a tiny part of EmberJS.

Editor's Notes

  1. !important clean chrome localstorage rd /q /s dist
  2. git checkout initial
  3. git checkout –f step-1
  4. git checkout –f step-2
  5. Vim e: package.json
  6. Git checkout –f step-3
  7. Stop ember serve (app/styles access race) git checkout –f step-4
  8. git checkout –f step-5
  9. git checkout –f step-6
  10. git checkout –f step-7
  11. git checkout –f step-8