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
240
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
39
Functional Ember
tchak
0
290
HTTP
tchak
3
190
Ember Data REBOOT
tchak
0
140
EmberJS Introduction
tchak
1
200
From SproutCore to Ember
tchak
2
250
Ember Data
tchak
11
830
Ember.js
tchak
10
1.6k
Other Decks in Programming
See All in Programming
CSC307 Lecture 11
javiergs
PRO
0
590
「やめとこ」がなくなった — 1月にZennを始めて22本書いた AI共創開発のリアル
atani14
0
350
メタプログラミングで実現する「コードを仕様にする」仕組み/nikkei-tech-talk43
nikkei_engineer_recruiting
0
160
CSC307 Lecture 15
javiergs
PRO
0
220
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
2
280
15年目のiOSアプリを1から作り直す技術
teakun
1
600
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
380
TipKitTips
ktcryomm
0
150
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
1
530
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
440
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
230
Python’s True Superpower
hynek
0
200
Featured
See All Featured
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
140
Balancing Empowerment & Direction
lara
5
930
The untapped power of vector embeddings
frankvandijk
2
1.6k
Statistics for Hackers
jakevdp
799
230k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
140
Color Theory Basics | Prateek | Gurzu
gurzu
0
230
Paper Plane
katiecoart
PRO
0
47k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
84
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
エンジニアに許された特別な時間の終わり
watany
106
240k
Between Models and Reality
mayunak
2
230
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
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