Last active
August 29, 2015 13:57
-
-
Save joseph/9766958 to your computer and use it in GitHub Desktop.
JS class pattern [2]
This file contains hidden or 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
// 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; | |
}); |
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
Also, you want to read this for getting AMD requires working in a CommonJS way reliably: http://requirejs.org/docs/whyamd.html#sugar