In my application are a couple of modules for their own responsibility, and that's where I have some confusion..
How to communicate between modules?
How to inform or listen modules between to take decision for appropriate scenario..?
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 both communicate and listen to each other..? Can anyone please clarify with some small example? I need to share the privateData shared to module2 and myPrivate name shared with module1 and in case of any click event to be triggered.
Thanks in advance!