and/or complexity • Sprinkling jQuery selectors only goes that far • Gives structure to your code • Let someone else do the hard stuff Sunday, October 13, 13
and/or complexity • Sprinkling jQuery selectors only goes that far • Gives structure to your code • Let someone else do the hard stuff • Less bugs Sunday, October 13, 13
updated iff any of the dependent properties change • Value is cached fullName: function() { return this.get('firstName') + ' ' + this.get('lastName'); }.property('firstName', 'lastName') Sunday, October 13, 13
= dbRef.child('users'); var wilmaRef = dbRef.child('users/wilma'); // or usersRef.child('wilma'); var rootRef = usersRef.parent(); Sunday, October 13, 13
“update()” keeps other data intact • “push()” to create unique child names in arrays • callback when data is persisted wilmaRef.update({ first: “Vilma”, last: “Erdi” }, function(error) { if(!error) { console.log('Data saved’); } }); Sunday, October 13, 13
• Any time data changes => snapshot • value, child_added, child_changed, child_removed, child_moved wilmaRef.on('value', function(snapshot) { console.log('First name is ' + snapshot.val().firstName); }); Sunday, October 13, 13
endAt() • they can be combined var usersList = usersRef.limit(10); usersList.on('child_added', function() { ... }); usersList.on('child_removed', function() { ... }); Sunday, October 13, 13
reflects the user’s availability • server timestamps • => a great fit for offline applications var lastOnline = usersRef.child('wilma/lastOnline'); lastOnline.onDisconnect().set(Firebase.ServerValue.TIMESTAMP); Sunday, October 13, 13