There are several modules in my application for their own responsibility and that I have some confusion.
Example:
module 1,
var MyModule1 = (function() {
var myPrivateData = 303;
function myPrivateFunction() {
alert('private');
}
return {
myPublicData : 42,
myPublicFunction : function() {
alert('public');
}
};
})();
Module 2
var MyModule2 = (function() {
var myPrivateName = privatized;
function myPrivateFunction() {
alert(myPrivateName) ;
}
return {
myPublicData : 42,
myPublicFunction : function() {
alert('public');
}
};
})();
How can I make them communicate and listen to each other.? Can anyone clarify with a small example? I need to share privateData shared with module 2 and the name myPrivate shared with module 1, and in case of any click event that needs to be fired.
Thanks in advance!
source
share