Skip to content

Instantly share code, notes, and snippets.

@joseph
Last active August 29, 2015 13:57
Show Gist options
  • Save joseph/9766958 to your computer and use it in GitHub Desktop.
Save joseph/9766958 to your computer and use it in GitHub Desktop.
JS class pattern [2]
// AMD module definition:
define(function (require) {
// An instantiable class:
var K = function () {
this._initialize();
this._p = {};
};
// A "private" method:
K.prototype._initialize = function () {
}
// A public method:
K.prototype.update = function () {
}
// A constant
K.MEANING_OF_LIFE = 42;
return K;
});
@joseph
Copy link
Author

joseph commented Mar 25, 2014

Also, you want to read this for getting AMD requires working in a CommonJS way reliably: http://requirejs.org/docs/whyamd.html#sugar

@joseph
Copy link
Author

joseph commented Mar 25, 2014

Oh, I had a confusing typo from my console experiments — see https://gist.github.com/joseph/9766958/revisions. The 'foo' did not belong, it was for testing only.

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