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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
ふつうのFeature Flag実践入門
irof
8
4k
RTSPクライアントを自作してみた話
simotin13
0
610
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
13k
dRuby over BLE
makicamel
2
380
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
270
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
710
Oxcを導入して開発体験が向上した話
yug1224
4
320
AI 輔助遺留系統現代化的經驗分享
jame2408
1
760
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
250
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
14
5.6k
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
110
JavaDoc 再入門
nagise
1
370
Featured
See All Featured
Building Adaptive Systems
keathley
44
3.1k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.4k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
150
Building the Perfect Custom Keyboard
takai
2
800
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Crafting Experiences
bethany
1
180
First, design no harm
axbom
PRO
2
1.2k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
260
Odyssey Design
rkendrick25
PRO
2
700
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
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.