Created
February 29, 2012 04:23
-
-
Save honbin/1937694 to your computer and use it in GitHub Desktop.
ファサードパターンお勉強1
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
//引用URL:http://addyosmani.com/resources/essentialjsdesignpatterns/book/ | |
var module = (function() { | |
var _private = { | |
i:5, | |
get : function() { | |
console.log( 'current value:' + this.i ); | |
}, | |
set : function(val) { | |
this.i = val; | |
}, | |
run : function() { | |
console.log( 'running' ); | |
}, | |
jumping : function() { | |
console.log( 'jumping' ); | |
} | |
}; | |
return { | |
facade : function( args) { | |
_private.set(args.val); | |
_private.get(); | |
if ( args.run ){ | |
_private.run(); | |
} | |
} | |
} | |
}()); | |
module.facade({run: true, val:10}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment