Skip to content

Instantly share code, notes, and snippets.

@phiggins42
Created July 13, 2009 12:54
Show Gist options
  • Save phiggins42/146095 to your computer and use it in GitHub Desktop.
Save phiggins42/146095 to your computer and use it in GitHub Desktop.
dojo.declare("my.Thinger", null, {
oneDefault:"string",
anotherDefault:42, // number
constructor: function(href, additionalOptions){
// if additionalOptions is null, nothing happens:
dojo.mixin(this, additionalOptions);
}
});
// all defaults:
new my.Thinger("foo.com");
// override default:
new my.Thinger("foo.com", { anotherDefault:27 });
// special notes about shared arrays and objects
dojo.declare("my.OtherThinger", null, {
// these two become shared by all instances of this class,
// because of JS's object referencing
sharedArray:[1,2,3],
sharedObject:{ a:"b" },
constructor: functionåç(args){
// this one is not shared by all instances of this class
// it is unique to this instance.
this.instanceObject = args.instanceObject || {};
this.insanceArray = args.instanceArray || [];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment