Skip to content

Instantly share code, notes, and snippets.

@poteto
Last active August 29, 2015 14:13
Show Gist options
  • Save poteto/7b997a249d9fb69b6aa0 to your computer and use it in GitHub Desktop.
Save poteto/7b997a249d9fb69b6aa0 to your computer and use it in GitHub Desktop.
import Ember from 'ember';
import notifyParents from 'notify-parents';
var observer = Ember.observer;
var computed = Ember.computed;
var not = computed.not;
var get = Ember.get;
export default Ember.Object.extend({
firstName: 'Lauren',
lastName: 'Tan',
isAtHome: false,
isOutside: not('isAtHome'),
fullName: computed('firstName', 'lastName', function() {
return get(this, 'firstName') + ' ' + get(this, 'lastName');
}),
notifyParentsWhenAtHome: observer('isAtHome', function() {
var userIsAtHome = get(this, 'isAtHome');
if (userIsAtHome) {
notifyParents(get(this, 'fullName'), new Date());
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment