By Igor Terzic / @terzicigor From Addepar
"Ember Camp: A small gathering of Ember developers designed to troll Tom&Yehuda about Ember Data" - Anonymous
user: {
id:1,
name: 'Igor',
slidesReady: false
}
1
1
1
user.get('name') -> 'Igor'
user.set('slidesReady', true)
user.save() -> POST /user/1
"The hooks now are insanely better" - Robert Jackson
App.UserSerializer = DS.RestSerializer.extend({
normalize: function(hash){
//DO CUSTOM CRAZY STUFF HERE
}
})
App.UserSerializer = DS.RestSerializer.extend({
extractSingle: function(store, primaryType, payload){
//DO EVEN CRAZIER STUFF HERE
},
extractArray: function(store, primaryType, payload){
//DO EVEN CRAZIER STUFF HERE
}
})
user.find()
user.onLoad( function(){
//DO THINGS
});
store.find('user', 1).then( function(data){
data.get('name')
});
comment = store.createRecord('comment')
post = store.createRecord('post')
post.save().then( function(data){
comment.set('post', data)
comment.save()
});
App.User = DS.Model.extend({
name: DS.attr('string'),
friends: DS.hasMany('user', {async: true])
})
App.User = DS.Model.extend({
name: DS.attr('string'),
friends: DS.hasMany('user', {async: false])
})
App.User = DS.Model.extend({
name: DS.attr('string'),
friends: DS.hasMany('user')
})
user.get('friends').then( function(friends){
//DO THINGS
});
user.get('friends').then( function(friends){
friends.objectAt(0).then( function(firstFriend) {
firstFriend.get('name');
});
});
user.get('friends').then( function(friends){
friends.objectAt(0).then( function(firstFriend) {
firstFriend.get('name');
});
});
user: function(){
store.find('user', 1)
}.property()
friends: function(){
this.get('user.friends')
}.property('user.friends')
//On App Load
var user1 = store.find('user', 1)
//In User Settings controller
var user2 = store.find('user', 1)
user1 == user2
var person = store.find('person', 1)
.
var samePerson = store.find('person', 1)
.
.
person.set('name', 'Igor')
samePerson.get('name') -> 'Igor'
store.find('user', 1)
Me.get('lightbulb')
store.find('user', 1)
user: { id:1,
name: 'Igor'
},
emails:[ {id:1, text: 'A Few Good Slides'}]
}
store.find('post', 1)
post: { id:1,
text: 'EmberConf IS Awesome',
comments: [54]
}
post: { id:1,
text: 'EmberConf IS Awesome',
comments: [54]
}
post.get('comments').length === 1
store.find('comment', 1)
comment: { id:1,
text: 'So Much Web',
post: 1 }
post.get('comments').length === 2