Skip to content

Instantly share code, notes, and snippets.

@benqus
Created March 16, 2015 16:08
Show Gist options
  • Save benqus/90bb934e8511fc4115ed to your computer and use it in GitHub Desktop.
Save benqus/90bb934e8511fc4115ed to your computer and use it in GitHub Desktop.
/**
* @class
* @classdesc The Job model class
*/
var Job = Model.extend({
idAttribute: 'resource_uri',
defaults: {
name: 'n/a'
},
keys: [ 'name' ]
});
// new job model instance
var job = new Job({ name: 'Print' }); // this is the same as Job.objects.create({ name: 'Print' });
// which one would you prefer? Knowing that the Model.objects (manager) notifies the subcsribers
// A
Job.onUpdate(function (event) {
var job = event.getModel(); // I'll keep this for generic event subscription
});
// B
Job.onUpdate(function (event, job) {
});
// C
Job.objects.onUpdate(function (event, job) {
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment