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
Ember Data: (Advanced) Patterns
Search
Paul Chavard
September 20, 2013
Programming
2
230
Ember Data: (Advanced) Patterns
Slides for my talk from EmberFest 2013
Paul Chavard
September 20, 2013
Tweet
Share
More Decks by Paul Chavard
See All by Paul Chavard
Le Tour du monde en quatre-vingts jours
tchak
1
38
Functional Ember
tchak
0
280
HTTP
tchak
3
190
Ember Data REBOOT
tchak
0
130
EmberJS Introduction
tchak
1
190
From SproutCore to Ember
tchak
2
250
Ember Data
tchak
11
820
Ember.js
tchak
10
1.6k
Other Decks in Programming
See All in Programming
バッチ処理を「状態の記録」から「事実の記録」へ
panda728
PRO
0
210
NIKKEI Tech Talk#38
cipepser
0
340
CSC305 Lecture 11
javiergs
PRO
0
320
Dive into Triton Internals
appleparan
0
320
Temporal Knowledge Graphで作る! 時間変化するナレッジを扱うAI Agentの世界
po3rin
5
1.1k
CSC305 Lecture 12
javiergs
PRO
0
240
AI時代に必須!状況言語化スキル / ai-context-verbalization
minodriven
2
240
KoogではじめるAIエージェント開発
hiroaki404
1
210
Researchlyの開発で参考にしたデザイン
adsholoko
0
100
フロントエンド開発のためのブラウザ組み込みAI入門
masashi
7
3.6k
Amazon ECS Managed Instances が リリースされた!キャッチアップしよう!! / Let's catch up Amazon ECS Managed Instances
cocoeyes02
0
110
Introduce Hono CLI
yusukebe
6
3.2k
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.1k
Leading Effective Engineering Teams in the AI Era
addyosmani
7
680
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
2.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.3k
Gamification - CAS2011
davidbonilla
81
5.5k
How to Ace a Technical Interview
jacobian
280
24k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
4 Signs Your Business is Dying
shpigford
186
22k
Unsuck your backbone
ammeep
671
58k
Transcript
Ember Data (Advanced) Patterns Paul Chavard Capitaine Train August 30,
2013
Capitaine Train capitainetrain.com • 55 controllers • 22 models
I am going to show you some useful stuff that
actualy works (most of the time) in Ember Data
Filters Dynamic Filter var IndexRoute = Ember.Route.extend ({ model: function
() { return this.store.filter(’post ’, {}, Ember.K); } }); var IndexController = Ember. ArrayController .extend ({ searchText : ’’, searchTextDidChange : function () { var searchText = this.get(’searchText ’). toLowerCase (); var filterFunction = Ember.isEmpty(searchText ) ? Ember.K : function(record) { return record.get(’title ’). toLowerCase () .match( searchText ); }; this.set(’content. filterFunction ’, filterFunction ); }. observes(’searchText ’) });
Batch Saves Save Multiple Models Ember.RSVP.all(post.get(’comments ’). invoke(’save ’)) .then(function
() { alert(’All Saved!’); }, function(reason) { alert(’There was an error because ’ + reason ); }); Save Parent Before Child post.save (). then(function () { return comment.save (); }). then(function () { alert(’All Saved!’); }, function(reason) { alert(’There was an error because ’ + reason ); });
Unload Records Unload Single Record this.store.find(’post ’, 1). unloadRecord ();
Unload Record with its Relationships var Post = DS.Model.extend ({ unloadRecord : function () { this._super (); this. eachRelationship (function(key , relationship ) { if ( relationship .kind === ’hasMany ’) { this.get(key ). toArray (). invoke(’unloadRecord ’); } else { this.get(key ). unloadRecord (); } }, this ); } }); this.store.find(’post ’, 1). unloadRecord ();
Ember Extention
The End