Created
August 6, 2016 02:52
-
-
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
This file contains 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
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