Share
Embed
Transcript
16 slides
-
Ember-‐Data A place to store all of your mistakes
1.0.0-‐beta.8 Nathan Dauber [email protected] -
Who’s this guy • Not Jim Halpert
• Senior Dev @ Radialogica • Leading Ember.js/Web development for Oncology AnalyKcs PlaMorm -
What’s Radialogica • Healthcare IT company focused on advanced
soPware soluKons for radiology and radiaKon oncology. • Our mission is to improve the safety, quality and efficiency of care with innovaKve tools that change how informaKon is accessed, analyzed and shared by members of the treatment team. -
Benefits • Model your domain • Interchangeable backend
(Adapter) • Caching Layer (Store) • Lazy loading • Side loading • Default data values • CustomizaKon -
Parts • Models • DS.Store • Adapters
• Serializers • Transformers -
DS.Model • DS.Model API • Defines a\ributes and
relaKonships • Supported Data Types – String/Bool/Dates/Numbers • Errors -
RelaKonships 1-‐1 DS.belongsTo DS.belongsTo 0-‐1
None DS.belongsTo 1-‐* DS.belongsTo DS.hasMany *-‐* DS.hasMany DS.hasMany 0-‐* None DS.hasMany -
DS.Store • h\p://emberjs.com/api/data/classes/ DS.Store.html • Caches all of
the data for records loaded from the server • Find One • Find Many • Find By Query -
DS.Adapter • DS.Adapter • ApplicaKonAdapter = Default Adapter
• Every model has Model-‐specific adapters – (ModelName + Adapter) – ApplicaKon Adapter is Backup • CustomizaKons – Headers – Hostname – Namespace -
DS.Adapter • Naming inconsistencies? No worries! – Ember.Inflector
Ac#on HTTP Verb URL Find GET /photos/123 Find All GET /photos Update PUT /photos/123 Create POST /photos Delete DELETE /photos/123 -
Serializers • Serialize records when they are transferred
out of the store. -
Transformers • De/Serialize model a\ributes – String/Date/Bool/Number •
You can write your own for your backend’s special datatypes -
Upcoming changes • Single Source of Truth – A
guarantee that if one side of a two-‐way relaKonship changes, the other side will remain in sync, even if it hasn't loaded yet. • {async = true} for All – DataBoundPromises will make them work well in observers, computed properKes and in templates. -
AlternaKves? • h\ps://github.com/getoutreach/epf • h\ps://github.com/gordonkristan/ember-‐ graph •
h\p://eviltrout.com/2013/03/23/ember-‐ without-‐data.html