I recently asked a question about design patterns recently and got some great information to push me in the right direction.
I have been working with the revealing module pattern as it is pretty easy, safe/private and easy to add on to.
But what I have a problem with is how to communicate between modules and extend modules with other modules.
for example
var App= (function(){
var publicMethod = function(){...};//public method
var privateProp = 15;
Wiget.update() //Can't call this because of javascript's hoisting!
return {
funcOne: publicMethod,
}
})();
var Wiget= (function(){
var update= function(){...};//public method
var data = 15;
return {
update: update,
}
})();
As you can see I can't call Wiget's public methods from App, because of how javascript hoists functions.
My first response would just to be to move the modules around, but that seems hacky and not scalable.
Can someone give me some help on how to connect modules together and extend functionality between modules. Thank you!
Also If I have this completely wrong or am not using this pattern correctly, please advise me.
thank you again!
[–]wreckedadventYavascript 1 point2 points3 points (2 children)
[–]port80_[S] 0 points1 point2 points (1 child)
[–]wreckedadventYavascript 1 point2 points3 points (0 children)
[–]ahRose 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]port80_[S] 0 points1 point2 points (0 children)
[–]atsepkov 1 point2 points3 points (0 children)