Skip to content

Instantly share code, notes, and snippets.

@carldanley
Last active May 14, 2016 04:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save carldanley/9187f369adcfc5c25e4f to your computer and use it in GitHub Desktop.
Save carldanley/9187f369adcfc5c25e4f to your computer and use it in GitHub Desktop.
A simple example of the facade pattern
var MyModule = ( function( window, undefined ) {
// revealing module pattern ftw
function MyModule() {
function someMethod() {
alert( 'some method' );
}
function someOtherMethod() {
alert( 'some other method' );
}
// expose publicly available methods
return {
// in our normal revealing module pattern, we'd do the following:
someMethod : someMethod,
// in the facade pattern, we mask the internals so no one has direct access by doing this:
someMethod : function() {
someMethod();
}
};
}
} )( window );
@mhulse
Copy link

mhulse commented May 14, 2016

@carldanley

Example call? Shouldn’t MyModule return something?

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