Skip to content

Instantly share code, notes, and snippets.

@albertoarena
Last active August 29, 2015 14:14
Show Gist options
  • Save albertoarena/bc03bef8915eb08bb42b to your computer and use it in GitHub Desktop.
Save albertoarena/bc03bef8915eb08bb42b to your computer and use it in GitHub Desktop.
Sample Person object using the getter/setter, as a RequireJS module
define(['getterSetter', function(getterSetter) {
return function(options) {
if (typeof options != 'object') {
options = {};
}
// We assume you can't change your name!
this.name = options.name;
// Role, e.g. Web developer
this.role = new getterSetter(options.role, options.onRoleChange);
// Salary, e.g. 30000
this.salary = new getterSetter(options.salary, options.onSalaryChange);
return this;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment