SlideShare ist ein Scribd-Unternehmen logo
1 von 97
Downloaden Sie, um offline zu lesen
Introduction To 
Desert Code Camp 
October 18, 2014 
Josh Padnick
You want to build the 
next great app.
Most of today’s apps 
use the same paradigm.
RESTful API 
Web Client Mobile Client Tablet Client
The app exposes a RESTful API. 
Then we can implement many 
potential clients against that API.
So what technologies 
should we use?
RESTful API 
For today’s talk, the API 
can be a black box. 
For Ember, it doesn’t even 
have to be RESTful, but 
we prefer that it is.
Tablet Client 
Mobile Client 
We could build native apps. 
But an HTML5 / CSS3 / JS web 
app will work, too.
Web Client 
For our web 
client, we have a 
few choices.
When does it make 
sense to choose Ember?
If you want to know what I think… 
Ember works great if: 
• You want to build a “desktop-app-like experience” in the 
browser 
• You’re dealing with moderate - high complexity in your app. 
• You want architectural guidance for the long-term at the 
cost of a steeper learning curve upfront. 
• You’re a javascript geek and want a “powerful framework” 
at your fingertips (API, great tools) and you don’t mind 
digging into the framework code base.
Actually, Ember works great for simple apps, too. 
But the question is: 
If you don’t know Ember already, when does it 
make sense to learn it?
Ember may not be worth the learning curve if: 
• Building a relatively simple app 
• You want to launch in less than 6 weeks from start. 
• You are brand new to javascript. 
• Ember works great for these use cases if you 
already know it! 
• Otherwise, Angular may be a better fit.
The Ember Learning Curve 
Easily Justify 
Your Salary! 
Productivity 
Key Concepts 
Understood 
Time for 
Ember Data 
Hello 
World 
Effort to Learn Week1 Week2 Week3 Week4 Week5 Week6 Week7 Week8 Week9 
Informally based on my experience + 2 colleagues 
Discover The Ember 
Way for yourself…
The Ember vs. Angular 
debate is ongoing. 
Here are some links for viewing at home: 
• http://www.benlesh.com/2014/04/embular-part-1-comparing-ember-and.html 
• http://discuss.emberjs.com/t/why-i-m-leaving-ember/6361 
• https://www.quora.com/Client-side-MVC/Is-Angular-js-or-Ember-js-the-better-choice- 
for-JavaScript-frameworks
My Goals for Today
1. Get you excited about Ember 
2. Give you a mental model that will 
accelerate your process of 
learning it.
What We’ll Cover Today
• Brief overview of the Ember ecosystem 
• See Ember in action 
• Show you the “Ember mental model” 
• Discuss The Ember Way™
About Me 
Josh Padnick 
josh.padnick@gmail.com 
602.432.3789 
http://JoshPadnick.com 
• About to launch medical appointment reminders product built in Ember. 
• Trained two engineers on Ember 
• Earned around 500 Stack Overflow reputation points for Ember answers. 
• Using Ember for a new startup project. 
• Professional AWS Consultant & Professional Trainer for EmberJS.
Special Thanks to the Ember Community! 
• I have had 100% of questions asked on StackOverflow and 
discuss.EmberJS.com answered. 
• I especially appreciate the responses of:
Overview
Three Players in the 
Ember Ecosystem
Ember 
Ember 
Data 
Ember 
CLI
Ember 
A framework for building ambitious web 
applications. 
• Helps you easily manage app state 
• Handles the boilerplate of building a web app 
• Gives you lots of tools to get your job done 
Ember 
Ember 
Data 
Ember 
CLI
Ember Data 
A library for robustly managing model data in your 
Ember.js applications. 
• Represents models in local browser store 
• Read/write with any persistence store (most 
commonly a RESTful API) 
• Kind of like an ORM for Javascript 
Ember 
Ember 
Data 
Ember 
CLI
Ember CLI 
The command-line interface for Ember 
• Instantly scaffold a new ember project 
• CLI-based unit and integration tests 
• One-command deployment 
• ES6 transpiling 
Ember 
Ember 
Data 
Ember 
CLI
Let’s See a Real Ember App
Later on, we’ll deal live 
with Ember code.
Mental Model
How We Go From… 
http://MyEmberApp.com/cats 
To… 
http://MyEmberApp.com/cats 
Trending Cat Pictures
GET http://MyEmberApp.com/cats 
User makes an HTTP GET Request
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Ember looks up /cats in the 
Ember App’s router.js
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Ember looks up this URL in the 
Ember App’s router.js
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Ember looks up this URL in the 
Ember App’s router.js 
ECMAscript 6 imports! 
ECMAscript 6 export 
Tells the Ember router how to handle 
URL changes (use the browser 
“history”, use a “#”, etc.)
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Ember looks up this URL in the 
Ember App’s router.js 
Ember uses lines 9 - 11 to map a given URL 
to a particular “state” in the app.
For now, you can think of “state” as 
the value of various properties, as 
well as the “currently active URL.”
Visualizing an Ember Routes File 
SOURCE: Ember.js in Action. Chapter 3.3. Joachim Haagen Skeie.
=
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Ember looks up /cats in the 
Ember App’s router.js
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Ember looks up this URL in the 
Ember App’s router.js 
Ember finds a “cats” route!
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js) 
Ember looks for a file corresponding 
to the cats route. It finds one, it 
loads the cats route.
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js) 
Ember looks for a file corresponding 
to the cats route. It finds one, so it 
loads the cats route. 
If Ember didn’t find a cats route, it would use 
Convention over Configuration to create one!
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js)
This shows a common use of the “model hook”. 
We tell Ember Data here to make an API call to GET /cats 
and then we’ll have these cats available for local use as Ember Records.
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js)
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js) 
Ember Data makes an HTTP GET request for “all cats” 
RESTful API
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js) 
The API responds. Ember Data stores the 
response locally as cat models. 
RESTful API
What’s a model? 
• A model is a class that defines the properties and 
behavior of the data that you present to the user. 
• Basically, a javascript object plus some Ember 
fanciness. 
• In Ember, models are defined by extending 
DS.Model. 
• An instance of a model is known as a “record” but it’s 
still just an instance of a DS.Model
Ember Model Basics 
• A model’s property can be a literal (as we saw 
with all of cat’s properties). 
• Or a model’s property can be to another model
’s Take on Ember Models 
• Your Ember models are a projection of your API’s 
models. 
• Your Ember models should be the projection of your 
“real” data model that makes sense for a local user. 
• My RDBMS may have a bunch of tables which I JOIN 
in a query, and I might represent that as a single 
Ember model. 
• Basically, think about how you want your data locally, 
and model accordingly.
Ember hopes you’ll give it JSON, 
but really it can handle anything. 
• Ember’s default adapter is called the 
DS.RESTAdapter and is based off of Ruby on 
Rails conventions. 
• I built an API using Play Framework (Java) and it 
was easy to tweak it to speak Ember. 
• If you can’t change the API, Ember provides 
serializers which let you do custom transforms 
between the API data that you actually get and 
the data format that Ember expects.
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js)
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js) 
Cats Controller 
(e.g. /controllers/cats.js) 
The route sets up the cats 
controller
Ember Controllers 
• “Controller” is probably the wrong term. 
• It’s really more of a view-model. 
• The controller’s job is to decorate the model. 
• If there’s a property that’s primarily for the UI, 
model it in the controller.
Ember Controllers 
• In a moment, we’re going to render our template. 
• When we do, the template will look to the controller to 
see what model is associated with this route. 
• You could either have a single model (e.g. one cat) or 
an array of models (e.g. many cats) associated with 
the route’s model. 
• Single cat —> Ember.ObjectController 
• Many cats —> Ember.ArrayController
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js) 
Cats Controller 
(e.g. /controllers/cats.js) 
The route sets up the cats 
ArrayController
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js) 
Cats Controller 
(e.g. /controllers/cats.js) 
The route sets up the cats 
ArrayController 
If Ember didn’t find a cats controller, 
it would use CoC to create one!
This property only makes sense in the UI. 
We wouldn’t store this in a database. 
This is known as a computed property. It updates 
when any property in the property() method changes.
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js) 
Cats Controller 
(e.g. /controllers/cats.js)
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js) 
Cats Controller 
(e.g. /controllers/cats.js) 
Cats View 
(e.g. /views/cats.js) 
The route sets up the cats view.
Ember Views 
• Ember views render a Handlebars template and 
insert it into the DOM. 
• I do occasionally use views to handle basic 
jQuery 
• But you’ll be surprised how rarely you use them. 
• That’s why I show the view in gray. You should 
be surprised that you’re using it.
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js) 
Cats Controller 
(e.g. /controllers/cats.js) 
Cats View 
(e.g. /views/cats.js)
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js) 
Cats Controller 
(e.g. /controllers/cats.js) 
Cats View 
(e.g. /views/cats.js) 
The view renders the cats 
Handlebars Template 
Cats Template 
(e.g. /templates/cats.js)
Ember Templates 
• Ember uses Handlebars to render templates. 
• Ember embraces the “logicless templates” 
paradigm, perhaps to a fault. 
• Templates are easy to learn, so I won’t spend 
much time on them, but here’s a quick example.
I want to show pictures of cats, 
so let’s add a pictureUrl 
property to the cat model.
For demo purposes only, 
we’re going to fudge the 
model in our route
And finally here’s our 
Handlebars template.
And now the cats 
themselves!
To summarize, here’s 
the flow we saw…
GET http://MyEmberApp.com/cats 
Router 
(router.js) 
Cats Route 
(e.g. /routes/cats.js) 
Cats Controller 
(e.g. /controllers/cats.js) 
Cats View 
(e.g. /views/cats.js) 
Cats Template 
(e.g. /templates/cats.js)
What We Didn’t Cover
Here’s the Ember 
universe of concepts.
• Templates 
• Components 
• Views 
• Naming Conventions (Resolver) 
• Ember Objects 
• Helpers 
• Routes 
• Router 
• Controllers 
• Models 
• Testing 
• Ember Data 
• Local Store 
• Initializers 
• Dependency Injection / 
Container 
• Run loop 
• Promises 
• Adapters 
• Serializers 
• Mixins
And here’s what we 
covered today…
• Templates 
• Components 
• Views 
• Naming Conventions (Resolver) 
• Ember Objects 
• Helpers 
• Routes 
• Router 
• Controllers 
• Models 
• Testing 
• Ember Data 
• Local Store (indirectly) 
• Initializers 
• Dependency Injection / 
Container 
• Run loop 
• Promises 
• Adapters (briefly) 
• Serializers (briefly) 
• Mixins
Those other concepts will be 
part of your learning curve.
Ember makes extensive use of promises. 
Once you understand them, they’re a 
pleasure, but until you do, things can feel 
hard. 
So spend time really getting familiar with them.
The Ember Way™
Ember is an opinionated 
framework. That means that it 
wants you to use a certain 
architecture.
The various ways in which you 
embrace Ember’s underlying 
opinions on architecture are known 
collectively as The Ember Way.
’s Take on The Ember Way 
1. It’s not authoritatively outlined anywhere. But be thinking about 
The Ember Way while you learn. 
2. Avoid direct DOM manipulation. Use Ember’s state management 
instead. This means avoiding jQuery plugins that do DOM 
manipulation. 
3. Leverage Ember’s bindings, computed properties, and observers. 
Update your templates by updating properties, not the DOM. 
4. Ember has lots of async going on, but if you learn each of the 
event hooks, it won’t bite you. 
5. Use your routes to update “model state” and controllers to update 
“view state”. Try to avoid handling model state in controllers.
Next Steps
Learning Ember 
• I find the CodeSchool.com EmberJS tutorial 
among the best. It’s $29/month. Stat here. 
• The EmberJS.com Guide is excellent, but only 
give you “the top 70% of the iceberg”. But use 
this as your starting point for reference. 
• The EmberJS API is indispensable. It’s 
important you learn how to use it. Also, always 
know what this refers to so that you can look 
up available properties in Ember.
Learn How to Debug Ember! 
• If you learn this skill, your ability to “fill in the 
mental model gaps” will be much easier, and 
your learning curve will shorten dramatically. 
• Everything you need is at this outstanding 12 
minute video by Robin Ward: 
http://eviltrout.com/2014/08/16/debugging-ember- 
js.html
Ramping Up on Ember 
• If you’re stuck, go to StackOverflow 
• If you’re curious about best practices or have a 
general question, use the Ember Discussion 
Forum.
Advanced Ember 
Here are some great resources for when you’re 
ready to dig in to the next level: 
• http://balinterdi.com/ 
• http://www.toptal.com/emberjs/a-thorough-guide- 
to-ember-data 
• http://emberwatch.com/ 
• http://eviltrout.com/
Thank you, 
Now go build something cool! 
Josh Padnick 
josh.padnick@gmail.com 
602.432.3789 
http://JoshPadnick.com

Weitere ähnliche Inhalte

Andere mochten auch

Ember Reusable Components and Widgets
Ember Reusable Components and WidgetsEmber Reusable Components and Widgets
Ember Reusable Components and WidgetsSergey Bolshchikov
 
Brief Introduction to Ember
Brief Introduction to EmberBrief Introduction to Ember
Brief Introduction to EmberVinay B
 
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
 
Play Framework: Intro & High-Level Overview
Play Framework: Intro & High-Level OverviewPlay Framework: Intro & High-Level Overview
Play Framework: Intro & High-Level OverviewJosh Padnick
 
Understanding the Nesting Structure of the Ember.js View Layer
Understanding the Nesting Structure of the Ember.js View LayerUnderstanding the Nesting Structure of the Ember.js View Layer
Understanding the Nesting Structure of the Ember.js View LayerKevin Ball
 
From 0 to Ember
From 0 to EmberFrom 0 to Ember
From 0 to EmberTracy Lee
 
Fun with Ember 2.x Features
Fun with Ember 2.x FeaturesFun with Ember 2.x Features
Fun with Ember 2.x FeaturesBen Limmer
 
RxJS Evolved
RxJS EvolvedRxJS Evolved
RxJS Evolvedtrxcllnt
 
Building a Single Page Application using Ember.js ... for fun and profit
Building a Single Page Application using Ember.js ... for fun and profitBuilding a Single Page Application using Ember.js ... for fun and profit
Building a Single Page Application using Ember.js ... for fun and profitBen Limmer
 
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
 
Ember Conf 2016: Building Mobile Apps with Ember
Ember Conf 2016: Building Mobile Apps with EmberEmber Conf 2016: Building Mobile Apps with Ember
Ember Conf 2016: Building Mobile Apps with EmberAlex Blom
 
AfriGadget @ Webmontag Frankfurt, June 6, 2011
AfriGadget @ Webmontag Frankfurt, June 6, 2011AfriGadget @ Webmontag Frankfurt, June 6, 2011
AfriGadget @ Webmontag Frankfurt, June 6, 2011Juergen Eichholz
 
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Chef
 
Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Chef
 

Andere mochten auch (20)

Ember Reusable Components and Widgets
Ember Reusable Components and WidgetsEmber Reusable Components and Widgets
Ember Reusable Components and Widgets
 
New AWS Services
New AWS ServicesNew AWS Services
New AWS Services
 
Agile Point
Agile PointAgile Point
Agile Point
 
Brief Introduction to Ember
Brief Introduction to EmberBrief Introduction to Ember
Brief Introduction to Ember
 
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
 
Play Framework: Intro & High-Level Overview
Play Framework: Intro & High-Level OverviewPlay Framework: Intro & High-Level Overview
Play Framework: Intro & High-Level Overview
 
Understanding the Nesting Structure of the Ember.js View Layer
Understanding the Nesting Structure of the Ember.js View LayerUnderstanding the Nesting Structure of the Ember.js View Layer
Understanding the Nesting Structure of the Ember.js View Layer
 
Attribute actions
Attribute actionsAttribute actions
Attribute actions
 
Demi-PDF
Demi-PDFDemi-PDF
Demi-PDF
 
EmberJS
EmberJSEmberJS
EmberJS
 
From 0 to Ember
From 0 to EmberFrom 0 to Ember
From 0 to Ember
 
Fun with Ember 2.x Features
Fun with Ember 2.x FeaturesFun with Ember 2.x Features
Fun with Ember 2.x Features
 
RxJS Evolved
RxJS EvolvedRxJS Evolved
RxJS Evolved
 
Building a Single Page Application using Ember.js ... for fun and profit
Building a Single Page Application using Ember.js ... for fun and profitBuilding a Single Page Application using Ember.js ... for fun and profit
Building a Single Page Application using Ember.js ... for fun and profit
 
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
 
Ember Conf 2016: Building Mobile Apps with Ember
Ember Conf 2016: Building Mobile Apps with EmberEmber Conf 2016: Building Mobile Apps with Ember
Ember Conf 2016: Building Mobile Apps with Ember
 
AfriGadget @ Webmontag Frankfurt, June 6, 2011
AfriGadget @ Webmontag Frankfurt, June 6, 2011AfriGadget @ Webmontag Frankfurt, June 6, 2011
AfriGadget @ Webmontag Frankfurt, June 6, 2011
 
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
 
Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3
 

Kürzlich hochgeladen

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
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
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%+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
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%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
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
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
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 

Kürzlich hochgeladen (20)

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
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
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+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...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%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
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
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
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 

Intro to EmberJS

  • 1. Introduction To Desert Code Camp October 18, 2014 Josh Padnick
  • 2. You want to build the next great app.
  • 3. Most of today’s apps use the same paradigm.
  • 4. RESTful API Web Client Mobile Client Tablet Client
  • 5. The app exposes a RESTful API. Then we can implement many potential clients against that API.
  • 6. So what technologies should we use?
  • 7. RESTful API For today’s talk, the API can be a black box. For Ember, it doesn’t even have to be RESTful, but we prefer that it is.
  • 8. Tablet Client Mobile Client We could build native apps. But an HTML5 / CSS3 / JS web app will work, too.
  • 9. Web Client For our web client, we have a few choices.
  • 10. When does it make sense to choose Ember?
  • 11.
  • 12. If you want to know what I think… Ember works great if: • You want to build a “desktop-app-like experience” in the browser • You’re dealing with moderate - high complexity in your app. • You want architectural guidance for the long-term at the cost of a steeper learning curve upfront. • You’re a javascript geek and want a “powerful framework” at your fingertips (API, great tools) and you don’t mind digging into the framework code base.
  • 13. Actually, Ember works great for simple apps, too. But the question is: If you don’t know Ember already, when does it make sense to learn it?
  • 14. Ember may not be worth the learning curve if: • Building a relatively simple app • You want to launch in less than 6 weeks from start. • You are brand new to javascript. • Ember works great for these use cases if you already know it! • Otherwise, Angular may be a better fit.
  • 15. The Ember Learning Curve Easily Justify Your Salary! Productivity Key Concepts Understood Time for Ember Data Hello World Effort to Learn Week1 Week2 Week3 Week4 Week5 Week6 Week7 Week8 Week9 Informally based on my experience + 2 colleagues Discover The Ember Way for yourself…
  • 16. The Ember vs. Angular debate is ongoing. Here are some links for viewing at home: • http://www.benlesh.com/2014/04/embular-part-1-comparing-ember-and.html • http://discuss.emberjs.com/t/why-i-m-leaving-ember/6361 • https://www.quora.com/Client-side-MVC/Is-Angular-js-or-Ember-js-the-better-choice- for-JavaScript-frameworks
  • 17. My Goals for Today
  • 18. 1. Get you excited about Ember 2. Give you a mental model that will accelerate your process of learning it.
  • 20. • Brief overview of the Ember ecosystem • See Ember in action • Show you the “Ember mental model” • Discuss The Ember Way™
  • 21. About Me Josh Padnick josh.padnick@gmail.com 602.432.3789 http://JoshPadnick.com • About to launch medical appointment reminders product built in Ember. • Trained two engineers on Ember • Earned around 500 Stack Overflow reputation points for Ember answers. • Using Ember for a new startup project. • Professional AWS Consultant & Professional Trainer for EmberJS.
  • 22. Special Thanks to the Ember Community! • I have had 100% of questions asked on StackOverflow and discuss.EmberJS.com answered. • I especially appreciate the responses of:
  • 24. Three Players in the Ember Ecosystem
  • 25. Ember Ember Data Ember CLI
  • 26. Ember A framework for building ambitious web applications. • Helps you easily manage app state • Handles the boilerplate of building a web app • Gives you lots of tools to get your job done Ember Ember Data Ember CLI
  • 27. Ember Data A library for robustly managing model data in your Ember.js applications. • Represents models in local browser store • Read/write with any persistence store (most commonly a RESTful API) • Kind of like an ORM for Javascript Ember Ember Data Ember CLI
  • 28. Ember CLI The command-line interface for Ember • Instantly scaffold a new ember project • CLI-based unit and integration tests • One-command deployment • ES6 transpiling Ember Ember Data Ember CLI
  • 29. Let’s See a Real Ember App
  • 30. Later on, we’ll deal live with Ember code.
  • 32. How We Go From… http://MyEmberApp.com/cats To… http://MyEmberApp.com/cats Trending Cat Pictures
  • 33. GET http://MyEmberApp.com/cats User makes an HTTP GET Request
  • 34. GET http://MyEmberApp.com/cats Router (router.js) Ember looks up /cats in the Ember App’s router.js
  • 35. GET http://MyEmberApp.com/cats Router (router.js) Ember looks up this URL in the Ember App’s router.js
  • 36. GET http://MyEmberApp.com/cats Router (router.js) Ember looks up this URL in the Ember App’s router.js ECMAscript 6 imports! ECMAscript 6 export Tells the Ember router how to handle URL changes (use the browser “history”, use a “#”, etc.)
  • 37. GET http://MyEmberApp.com/cats Router (router.js) Ember looks up this URL in the Ember App’s router.js Ember uses lines 9 - 11 to map a given URL to a particular “state” in the app.
  • 38. For now, you can think of “state” as the value of various properties, as well as the “currently active URL.”
  • 39. Visualizing an Ember Routes File SOURCE: Ember.js in Action. Chapter 3.3. Joachim Haagen Skeie.
  • 40. =
  • 41. GET http://MyEmberApp.com/cats Router (router.js) Ember looks up /cats in the Ember App’s router.js
  • 42. GET http://MyEmberApp.com/cats Router (router.js) Ember looks up this URL in the Ember App’s router.js Ember finds a “cats” route!
  • 43. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js) Ember looks for a file corresponding to the cats route. It finds one, it loads the cats route.
  • 44. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js) Ember looks for a file corresponding to the cats route. It finds one, so it loads the cats route. If Ember didn’t find a cats route, it would use Convention over Configuration to create one!
  • 45. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js)
  • 46.
  • 47.
  • 48. This shows a common use of the “model hook”. We tell Ember Data here to make an API call to GET /cats and then we’ll have these cats available for local use as Ember Records.
  • 49. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js)
  • 50. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js) Ember Data makes an HTTP GET request for “all cats” RESTful API
  • 51. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js) The API responds. Ember Data stores the response locally as cat models. RESTful API
  • 52. What’s a model? • A model is a class that defines the properties and behavior of the data that you present to the user. • Basically, a javascript object plus some Ember fanciness. • In Ember, models are defined by extending DS.Model. • An instance of a model is known as a “record” but it’s still just an instance of a DS.Model
  • 53.
  • 54. Ember Model Basics • A model’s property can be a literal (as we saw with all of cat’s properties). • Or a model’s property can be to another model
  • 55. ’s Take on Ember Models • Your Ember models are a projection of your API’s models. • Your Ember models should be the projection of your “real” data model that makes sense for a local user. • My RDBMS may have a bunch of tables which I JOIN in a query, and I might represent that as a single Ember model. • Basically, think about how you want your data locally, and model accordingly.
  • 56. Ember hopes you’ll give it JSON, but really it can handle anything. • Ember’s default adapter is called the DS.RESTAdapter and is based off of Ruby on Rails conventions. • I built an API using Play Framework (Java) and it was easy to tweak it to speak Ember. • If you can’t change the API, Ember provides serializers which let you do custom transforms between the API data that you actually get and the data format that Ember expects.
  • 57. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js)
  • 58. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js) Cats Controller (e.g. /controllers/cats.js) The route sets up the cats controller
  • 59. Ember Controllers • “Controller” is probably the wrong term. • It’s really more of a view-model. • The controller’s job is to decorate the model. • If there’s a property that’s primarily for the UI, model it in the controller.
  • 60.
  • 61. Ember Controllers • In a moment, we’re going to render our template. • When we do, the template will look to the controller to see what model is associated with this route. • You could either have a single model (e.g. one cat) or an array of models (e.g. many cats) associated with the route’s model. • Single cat —> Ember.ObjectController • Many cats —> Ember.ArrayController
  • 62. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js) Cats Controller (e.g. /controllers/cats.js) The route sets up the cats ArrayController
  • 63. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js) Cats Controller (e.g. /controllers/cats.js) The route sets up the cats ArrayController If Ember didn’t find a cats controller, it would use CoC to create one!
  • 64. This property only makes sense in the UI. We wouldn’t store this in a database. This is known as a computed property. It updates when any property in the property() method changes.
  • 65. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js) Cats Controller (e.g. /controllers/cats.js)
  • 66. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js) Cats Controller (e.g. /controllers/cats.js) Cats View (e.g. /views/cats.js) The route sets up the cats view.
  • 67. Ember Views • Ember views render a Handlebars template and insert it into the DOM. • I do occasionally use views to handle basic jQuery • But you’ll be surprised how rarely you use them. • That’s why I show the view in gray. You should be surprised that you’re using it.
  • 68. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js) Cats Controller (e.g. /controllers/cats.js) Cats View (e.g. /views/cats.js)
  • 69. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js) Cats Controller (e.g. /controllers/cats.js) Cats View (e.g. /views/cats.js) The view renders the cats Handlebars Template Cats Template (e.g. /templates/cats.js)
  • 70. Ember Templates • Ember uses Handlebars to render templates. • Ember embraces the “logicless templates” paradigm, perhaps to a fault. • Templates are easy to learn, so I won’t spend much time on them, but here’s a quick example.
  • 71. I want to show pictures of cats, so let’s add a pictureUrl property to the cat model.
  • 72.
  • 73. For demo purposes only, we’re going to fudge the model in our route
  • 74.
  • 75. And finally here’s our Handlebars template.
  • 76.
  • 77. And now the cats themselves!
  • 78.
  • 79. To summarize, here’s the flow we saw…
  • 80. GET http://MyEmberApp.com/cats Router (router.js) Cats Route (e.g. /routes/cats.js) Cats Controller (e.g. /controllers/cats.js) Cats View (e.g. /views/cats.js) Cats Template (e.g. /templates/cats.js)
  • 82. Here’s the Ember universe of concepts.
  • 83. • Templates • Components • Views • Naming Conventions (Resolver) • Ember Objects • Helpers • Routes • Router • Controllers • Models • Testing • Ember Data • Local Store • Initializers • Dependency Injection / Container • Run loop • Promises • Adapters • Serializers • Mixins
  • 84. And here’s what we covered today…
  • 85. • Templates • Components • Views • Naming Conventions (Resolver) • Ember Objects • Helpers • Routes • Router • Controllers • Models • Testing • Ember Data • Local Store (indirectly) • Initializers • Dependency Injection / Container • Run loop • Promises • Adapters (briefly) • Serializers (briefly) • Mixins
  • 86. Those other concepts will be part of your learning curve.
  • 87. Ember makes extensive use of promises. Once you understand them, they’re a pleasure, but until you do, things can feel hard. So spend time really getting familiar with them.
  • 89. Ember is an opinionated framework. That means that it wants you to use a certain architecture.
  • 90. The various ways in which you embrace Ember’s underlying opinions on architecture are known collectively as The Ember Way.
  • 91. ’s Take on The Ember Way 1. It’s not authoritatively outlined anywhere. But be thinking about The Ember Way while you learn. 2. Avoid direct DOM manipulation. Use Ember’s state management instead. This means avoiding jQuery plugins that do DOM manipulation. 3. Leverage Ember’s bindings, computed properties, and observers. Update your templates by updating properties, not the DOM. 4. Ember has lots of async going on, but if you learn each of the event hooks, it won’t bite you. 5. Use your routes to update “model state” and controllers to update “view state”. Try to avoid handling model state in controllers.
  • 93. Learning Ember • I find the CodeSchool.com EmberJS tutorial among the best. It’s $29/month. Stat here. • The EmberJS.com Guide is excellent, but only give you “the top 70% of the iceberg”. But use this as your starting point for reference. • The EmberJS API is indispensable. It’s important you learn how to use it. Also, always know what this refers to so that you can look up available properties in Ember.
  • 94. Learn How to Debug Ember! • If you learn this skill, your ability to “fill in the mental model gaps” will be much easier, and your learning curve will shorten dramatically. • Everything you need is at this outstanding 12 minute video by Robin Ward: http://eviltrout.com/2014/08/16/debugging-ember- js.html
  • 95. Ramping Up on Ember • If you’re stuck, go to StackOverflow • If you’re curious about best practices or have a general question, use the Ember Discussion Forum.
  • 96. Advanced Ember Here are some great resources for when you’re ready to dig in to the next level: • http://balinterdi.com/ • http://www.toptal.com/emberjs/a-thorough-guide- to-ember-data • http://emberwatch.com/ • http://eviltrout.com/
  • 97. Thank you, Now go build something cool! Josh Padnick josh.padnick@gmail.com 602.432.3789 http://JoshPadnick.com