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
メモリ不足との戦い〜大量データを扱うアプリでの実践例〜
kwzr
1
880
(Extension DC 2025) Actor境界を越える技術
teamhimeh
1
230
uniqueパッケージの内部実装を支えるweak pointerの話
magavel
0
920
プログラミングどうやる? ~テスト駆動開発から学ぶ達人の型~
a_okui
0
190
株式会社 Sun terras カンパニーデック
sunterras
0
230
プログラマのための作曲入門
cheebow
0
540
タスクの特性や不確実性に応じた最適な作業スタイルの選択(ペアプロ・モブプロ・ソロプロ)と実践 / Optimal Work Style Selection: Pair, Mob, or Solo Programming.
honyanya
3
140
ABEMAモバイルアプリが Kotlin Multiplatformと歩んだ5年 ─ 導入と運用、成功と課題 / iOSDC 2025
akkyie
0
330
Model Pollution
hschwentner
1
180
明日から始めるリファクタリング
ryounasso
0
120
高度なUI/UXこそHotwireで作ろう Kaigi on Rails 2025
naofumi
4
3.5k
Introducing ReActionView: A new ActionView-Compatible ERB Engine @ Kaigi on Rails 2025, Tokyo, Japan
marcoroth
3
920
Featured
See All Featured
Speed Design
sergeychernyshev
32
1.1k
Testing 201, or: Great Expectations
jmmastey
45
7.7k
Making the Leap to Tech Lead
cromwellryan
135
9.5k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
GitHub's CSS Performance
jonrohan
1032
460k
Producing Creativity
orderedlist
PRO
347
40k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.6k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
140
34k
Mobile First: as difficult as doing things right
swwweet
224
10k
It's Worth the Effort
3n
187
28k
Practical Orchestrator
shlominoach
190
11k
Writing Fast Ruby
sferik
629
62k
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