Created
March 16, 2015 16:08
-
-
Save benqus/90bb934e8511fc4115ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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