Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zoolu-got-rhythm/efd87beff57dee392f13e9557ed70e6c to your computer and use it in GitHub Desktop.
Save zoolu-got-rhythm/efd87beff57dee392f13e9557ed70e6c to your computer and use it in GitHub Desktop.
Subscriber pattern? how do i access methods from submodule 1 from inside submodule 2
var superModule = (function(){
// global state
return {
submodule1:{
// contains some internal state
// contains methods
},
submodule2:{
// contains some internal state
// contains methods
}
}
})();
superModule.submodule1.init();
// OR THIS IMPLEMENTATION THAT USES MODULE PATTERNS IN SUB-MODULE TOO!
// or the submodule can be closues for private internal state
var superModule = (function(){
// global state
return {
submodule1: (function(){
// internal state
return {
// methods
}
})(),
submodule2: (function(){
// internal state
return {
// methods
}
})()
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment