Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
15 Things You Shouldn't Do In Ember Anymore
Search
Kerrick Long
August 03, 2015
Programming
1.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
15 Things You Shouldn't Do In Ember Anymore
Kerrick Long
August 03, 2015
More Decks by Kerrick Long
See All by Kerrick Long
The ECMAScript formerly known as 6
kerrick
0
1.4k
CSS Study Group 1
kerrick
0
1.3k
CSS Study Group 2
kerrick
1
1.1k
Services & Component Collaboration
kerrick
0
810
Donate STL #Build4STL Hackathon Keynote
kerrick
0
420
Donate STL
kerrick
0
840
TDD With Ember.js
kerrick
0
1.3k
JavaScript Promises - Thinking Sync in an Async World
kerrick
20
8.4k
Other Decks in Programming
See All in Programming
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
260
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
550
技術記事、 専門家としてのプログラマ、 言語化
mizchi
13
6.2k
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
11
5.8k
C# and C++ Interoperability - cho-dotnetnew
harukasao
0
260
Creating Composable Callables in Contemporary C++
rollbear
0
150
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
180
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
170
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
400
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
410
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.7k
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
The Spectacular Lies of Maps
axbom
PRO
1
820
Mobile First: as difficult as doing things right
swwweet
225
10k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Rails Girls Zürich Keynote
gr2m
96
14k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
850
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.3k
30 Presentation Tips
portentint
PRO
1
330
Transcript
15 Things You shouldn’t be doing in Ember.js anymore
Kerrick Long Things I make and do Where to find
me online twitter.com/KerrickLong github.com/Kerrick Lead Front-end Developer at Second Street KerrickLong.com www. meetup.com/ STLEmber
Not using Ember CLI
npm install -g ember-cli ember new my-project
Using needs in Controllers
import Ember from 'ember'; export default Ember.Controller.extend({ needs: ['pages'],
title: 'controllers.pages.model.title' }); Using needs in Controllers
import Ember from 'ember'; export default Ember.Controller.extend({ pages: Ember.inject.controller(),
title: 'pages.model.title' }); Using inject in Controllers
import Ember from 'ember'; export default Ember.Controller.extend({ foo: Ember.inject.controller('pages'),
title: 'foo.model.title' }); Using inject in Controllers
Computed properties with getter / setter in one function
import Ember from 'ember'; export default Em.Service.extend({ minutes: 480,
hours: Em.computed('minutes', function(k, v) { if (arguments.length > 1) { this.set('minutes', v * 60); } return this.get('minutes') / 60; }) }); Computed getter / setter
Computed getter / setter import Ember from 'ember'; export
default Em.Service.extend({ minutes: 480, hours: Em.computed('minutes', { get() { return this.get('minutes') / 60; }, set(k, v) { return this.set('minutes', v * 60); } }) });
Using this.resource in the router
Using this.resource Router.map(function() { this.resource('pages', function() { this.resource('comments'); }); });
// app/routes/comments/index.js export default Ember.Route.extend({ model() { return this.store.find('comments'); } });
Using this.resource Router.map(function() { this.route('pages', function() { this.route('comments'); }); });
// app/routes/pages/comments/index.js export default Ember.Route.extend({ model() { return this.store.find('comments'); } });
Using {{bind- attr}}
Using {{bind-attr}} <button {{bind-attr title=buttonTitle}}> Submit! </button>
Using {{bind-attr}} <button title={{buttonTitle}}> Submit! </button>
{{#each}} without as
{{#each}} with in <ul> {{#each messages}} <li>{{text}}</li> {{/each}} </ul>
{{#each}} with in <ul> {{#each message in messages}} <li>{{message.text}}</li> {{/each}}
</ul>
{{#each}} with in <ul> {{#each messages as |message|}} <li>{{message.text}}</li> {{/each}}
</ul>
Using the {{render}} helper
The {{render}} helper <div> {{render "my-controller" model}} </div>
The {{render}} helper <div> {{my-component thing=model}} </div>
Using the {{view}} helper
ember g component new-way
Using Ember.Select
Using {{view "select"}} {{view "select" content=model.pages optionValuePath="content.id" optionLabelPath="content.title" prompt="-- Select
One --" }}
Using {{view "select"}} “Make your own.” http://emberjs.com/deprecations/v1.x/#toc_ember-select
Using {{view "select"}} “Make your own.” http://emberjs.com/deprecations/v1.x/#toc_ember-select Or use a
legacy addon.
Creating arrayComputed properties
Using arrayComputed import Ember from 'ember'; export default Ember.Controller.extend({
uniqueChildren: Ember.arrayComputed('
[email protected]
.[]', { addedItem: function(accumulatedValue, model) { accumulatedValue.addObjects(model.get('children')); return accumulatedValue.uniq(); }, removedItem: function(accumulatedValue, model) { accumulatedValue.removeObjects(model.get('children')); return accumulatedValue.uniq(); } }) });
Using arrayComputed import Ember from 'ember'; export default Ember.Controller.extend({
uniqueChildren: Ember.computed('
[email protected]
.[]', function() { return _.flatten(this.get('model').map(x => x.get('children'))).uniq(); }) });
Creating reduceComputed properties
Using reduceComputed import Ember from 'ember'; export default Ember.Controller.extend({
total: Ember.reduceComputed('
[email protected]
', { initialValue: 0, addedItem(accumulatedValue, item) { return accumulatedValue + item.get('value'); }, removedItem(accumulatedValue, item) { return accumulatedValue - item.get('value'); } }) });
Using reduceComputed import Ember from 'ember'; export default Ember.Controller.extend({
total: Ember.computed('
[email protected]
', function() { const addValues = (p, x) => p + x.get('value'); return this.get('model').reduce(addValues, 0); }) });
Using ObjectController
Using ObjectController import Ember from 'ember'; export default Ember.ObjectController.extend({
foo: Ember.computed.not('bar') });
Using ObjectController import Ember from 'ember'; export default Ember.Controller.extend({
foo: Ember.computed.not('model.bar') });
Using ArrayController
Using ArrayController import Ember from 'ember'; export default Ember.ArrayController.extend({
sortProperties: ['date', 'name'] // You can use `arrangedContent` });
Using ArrayController import Ember from 'ember'; export default Ember.Controller.extend({
arrangedContent: Ember.computed.sort(/**/) });
Using {{#each}} with itemController
ember g component new-way
Mutating data in components
Parent Child data manipulation manipulation source of data
Parent Child data manipulation source of data
Parent Child data manipulation actions regarding user input or intent
source of data
Thank you.