Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Data Loading Patterns with JSON API
Search
Balint Erdi
March 28, 2017
Technology
1.5k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Data Loading Patterns with JSON API
The talk I gave at EmberConf 2017, on 03/28/2017
Balint Erdi
March 28, 2017
More Decks by Balint Erdi
See All by Balint Erdi
Why you should consider Ember.js for your next project
balint
4
370
Data Loading Patterns in Ember
balint
1
260
Auth* in Ember apps with Torii
balint
1
330
(Somewhat) Complex Component Design – Ember.BP, 2015/02/11
balint
1
120
Complex Component Design in Ember
balint
0
410
Don't call me back - How Ember uses promises and how you can, too
balint
5
11k
Acceptance testing in Ember.js
balint
1
540
Unit testing in Ember.js
balint
0
120
Introduction to ember-data
balint
0
190
Other Decks in Technology
See All in Technology
Execution in the Kingdom of Agents: Reflections on Abstraction and Complexity
bcantrill
0
900
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
760
おそらく日本で唯一のDevRelインターン生として
husengs7
0
170
事業活動を AI Ready にする攻めと守りのデータエンジニアリング / data-engineering-for-ai-ready-business
pei0804
7
2.4k
組み立てて楽しむ AWS Blocks 入門
kmiya84377
0
230
全PRの83%が AIレビューだけでマージできるようになった開発組織は その後どうなったか @2026/10
athug
0
140
味覇で作るパスタが美味い - 20261001_yabaubuki.dev
livesense
PRO
0
120
カンファレンスに参加した後の浮遊感とセルフケア
pauli
0
320
AI 時代の Azure エンジニアリング ~ 私たちは何を磨き、何を任せるのか ~
chack411
1
570
Claude Code本は、どのように執筆チームで書かれたか
oikon48
1
360
Codex概要
ymiya55
0
500
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
1
1.6k
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
580
Become a Pro
speakerdeck
PRO
31
6.3k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
How to make the Groovebox
asonas
2
2.5k
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
860
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
The Invisible Side of Design
smashingmag
301
52k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
630
Transcript
Data Loading Patterns EmberConf 2017, Portland 03/28/2017
Data Loading Patterns with JSON API EmberConf 2017, Portland 03/28/2017
This talk is going to be … • A series
of prevalent use cases • Rich in code examples • Packed with actionable advice
Why JSON API?
What kind of API? • Backend dev: “What kind of
API are we going to use?” • Me: “JSON API” • We: “Let’s start working then”
CoC for APIs
Covering The Basics
Covering the basics (ED) • store.findRecord(‘band’, 1) • if the
record is in the store => returns it, and re-fetches it in the background • if the record is not in the store => returns a promise
Covering the basics (ED) • store.findAll(‘band’) • if >= 1
record in the store => returns them and triggers a refetch in the bg. • if there is no record in the store => returns a promise to fetch all of them
Covering the basics (ED) • store.peekRecord(‘band’, 1) • never triggers
a reload • returns the record if it’s in the store • returns null if it’s not
Covering the basics (ED) • store.peekAll(‘band’) • never triggers a
reload • returns the records already in the store
Covering the basics (ED) • shouldBackgroundReloadRecord • shouldBackgroundReloadAll • configurable
on the adapter
Covering the basics (Ember) • The model hooks are resolved
top-down • A child route is not entered before the hooks are run for its parent
Covering the basics (Ember) • Returning a promise in the
model hook “blocks” rendering the page • `findRecord`, `findAll`, `query` all return promises
The app
application bands bands.band.songs bands.band
Balint Erdi @baaz balinterdi.com Ember.js consultant
Case Studies
Fetching Relationship Data
Lazy Fetching
None
None
Pros & cons • Simple, works out of the box
• On-demand data fetching • Might trigger N requests • Disturbing flicker
Pre-loading the relationship
None
None
Move relationship data fetching to the route’s model hook if
you want to block rendering
Pros & cons • Better UX than the lazy fetching
scenario • Might still trigger N requests • RSVP.hash in the model hook is considered an anti-pattern
Side-loading
“An endpoint MAY also support an include request parameter to
allow the client to customize which related resources should be returned.”
None
None
None
None
Why is there a flicker? Shouldn’t the songs be side-loaded
and only then the page rendered?
None
None
None
Pros & cons • We leverage JSON:API • Explicit control
over fetching relationship data • Delays the rendering of the band template
Honorable mention: References API (ED 2.5)
Data loading strategy should be part of the design process
Searching on the Backend
“The filter query parameter is reserved for filtering data. Servers
and clients SHOULD use this key for filtering operations.”
None
None
Does a global search
None
None
Use a JSON API filter and query the relationship
Sorting
“An endpoint MAY support requests to sort the primary data
with a sort query parameter. The value for sort MUST represent sort fields.”
“The sort order for each sort field MUST be ascending
unless it is prefixed with a minus (U+002D HYPHEN-MINUS, “-“), in which case it MUST be descending.”
None
None
None
Use the JSON API `sort` parameter without transform
Pagination
“A server MAY choose to limit the number of resources
returned in a response to a subset (“page”) of the whole set available.”
“Note: JSON API is agnostic about the pagination strategy used
by a server. (…) The page query parameter can be used as a basis for any of these strategies.”
“Where specified, a meta member can be used to include
non-standard meta- information. The value of each meta member MUST be an object (a “meta object”).”
None
None
None
None
Use JSON API’s `page` parameters and pagination meta data
Indicating ongoing background record fetching
None
None
None
None
None
Eager return
None
None
Deconstruct the background data fetching process to have more control
over the loading process
Use ember-concurrency
None
No manual loading flag setting, run loop scheduling and reload
option setting
https://balinterdi.com/ emberconf
None
References • Rock and Roll with Ember book • {json:api}
specification • JSONAPI::Resources docs site • ember-concurrency or How I Learned to Stop Worrying and Love the Task on LinkedIn Enginnering • Lessons learned from four years with Ember by Ryan Toronto