Skip to content

Instantly share code, notes, and snippets.

@phiggins42
Created March 30, 2011 14:53
Show Gist options
  • Save phiggins42/894544 to your computer and use it in GitHub Desktop.
Save phiggins42/894544 to your computer and use it in GitHub Desktop.
dojo.provide("Foo"); // always first
dojo.require("All.Your.Code.Are"); // always second
dojo.require("Belong.To.Us");
(function(d){ // optional wrapper / privatizer / closure
// privates for this module
var yep = true,
nope = false,
helperUpper = function(str){
return str.toUpperCase()
}
;
// declarations
dojo.declare("MyTHing", [inheritanceChain], {
member1: "Public members listed first in declcartion",
anumber: 42,
etc: "and so on",
// private members, too:
_test: 1,
_test2: 3,
_test5: "etc",
// begin lifecycle overrides
postMixInProperties: function(){
dojo.mixin(this, { something:"random" });
this.connect(this.domNode, "click", "awesomeFunction");
this.inherited(arguments);
},
// and so on
// begin public class members
awesomeFunction: function(e){
this.foobar = this.oneMore("time");
},
_privateHelperForAwesomeFunction: function(e){
// should be immediately following the function it helps
},
anotherAwesomePublicFunction: function(){},
oneMore: function(arg){
return helperUpper(arg);
},
// unless it's super generic, then it goes at the bottom.
_count: function(f){
}
});
})(dojo);
@phiggins42
Copy link
Author

not with es3 ... which is everywhere. modern browsers you could use defineGetter et al and accomplish this, but I'm a pragmatist and also still have to support ie6 in most things, so it's more of a pipe dream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment