Ember Data
Adam Kloboučník, GoodData
@akloboucnik

GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
Ember Data

▶

client data-persistence library
▶

▶

▶

for Ember.js

still beta-quality
strongly opinionated (naming, url...
Complications

Data

merge problems
Web Applications

GoodData Confidential. 2013 GoodData Corporation. All rights reserve...
Complications
User

Post

dirty checking

Comment
changes

GoodData Confidential. 2013 GoodData Corporation. All rights re...
Complications

▶

▶

▶

merge problems
dirty checking
async

GoodData Confidential. 2013 GoodData Corporation. All rights ...
Ember Data architecture
TA
ES

Lo
c

alS

PI

tor

ag
e

R

Data

“Talks”
protocol

Persists models

Adapter

Store

Seria...
Models

App.Post = DS.Model.extend({
title: DS.attr('string'),
body: DS.attr('string'),
comments: DS.hasMany('comment', {a...
Adapter

▶

▶

▶

provides protocol abstraction
RESTAdapter, FixtureAdapter provided
LocalStorageAdapter, many others...

...
Intermezzo - promises

▶

“eventual value returned from completion of operation”
function callApi(id) {
var promise = long...
Store

▶

▶

▶

▶

querying and saving
store.find[All,Query](‘model-name’[, id]);
model_object.save();
both finders and sa...
Notes

▶

▶

▶

identity map
sideloading
optimize you API for easier life (jsonapi.org)
▶
▶

▶

alternatives
▶
▶
▶

▶

act...
Conclusion

▶

▶

really young now, but
provides clean separation of concerns
▶
▶
▶

▶

▶

developing client app without b...
Thank you!
@akloboucnik

GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
Upcoming SlideShare
Loading in …5
×

Ember Data Introduction and Basic Concepts

726 views
555 views

Published on

Slides for talk given on November PragueJS meetup (http://www.praguejs.cz/talks/#november-2013)

Published in: Technology, Art & Photos
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total views
726
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Ember Data Introduction and Basic Concepts

  1. 1. Ember Data Adam Kloboučník, GoodData @akloboucnik GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
  2. 2. Ember Data ▶ client data-persistence library ▶ ▶ ▶ for Ember.js still beta-quality strongly opinionated (naming, url + model schema) ▶ “trivial choices are enemy” ~ @wycats GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
  3. 3. Complications Data merge problems Web Applications GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
  4. 4. Complications User Post dirty checking Comment changes GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
  5. 5. Complications ▶ ▶ ▶ merge problems dirty checking async GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
  6. 6. Ember Data architecture TA ES Lo c alS PI tor ag e R Data “Talks” protocol Persists models Adapter Store Serializer Models Google Spreadsheet Extracts raw data to Models GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
  7. 7. Models App.Post = DS.Model.extend({ title: DS.attr('string'), body: DS.attr('string'), comments: DS.hasMany('comment', {async: true}) }); App.Comment = DS.Model.extend({ content: DS.attr('string'), post: DS.belongsTo('post') }); GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
  8. 8. Adapter ▶ ▶ ▶ provides protocol abstraction RESTAdapter, FixtureAdapter provided LocalStorageAdapter, many others... GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
  9. 9. Intermezzo - promises ▶ “eventual value returned from completion of operation” function callApi(id) { var promise = longRunningOperation(id); return promise; } //.... callApi(2).then(function(result) { // do sth with resolved result }, function(err) { // do sth with rejection }); GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
  10. 10. Store ▶ ▶ ▶ ▶ querying and saving store.find[All,Query](‘model-name’[, id]); model_object.save(); both finders and save return promises for developer sanity (formerly a state chart with actions on edges) ▶ Em.RSVP.all([promise1, promise2]).then ... GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
  11. 11. Notes ▶ ▶ ▶ identity map sideloading optimize you API for easier life (jsonapi.org) ▶ ▶ ▶ alternatives ▶ ▶ ▶ ▶ active_model_serializers in Rails :-( elsewhere Ember.Resource Ember.Model EPF sources - emberjs.com/guides, source GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
  12. 12. Conclusion ▶ ▶ really young now, but provides clean separation of concerns ▶ ▶ ▶ ▶ ▶ developing client app without backend testing adapter code without rest of the app … “best practices” for api modelling integrates greatly with Ember if you use it GoodData Confidential. 2013 GoodData Corporation. All rights reserved.
  13. 13. Thank you! @akloboucnik GoodData Confidential. 2013 GoodData Corporation. All rights reserved.

×