Tuesday, August 28, 2012

Event Aggregation In Javascript

The Event Aggregator service is primarily a container for events that allow decoupling of publishers and subscribers so they can evolve independently. This decoupling is useful in modularized applications because new modules can be added that respond to events defined by the shell or, more likely, other modules.

Ff921122.fdbe7d1c-f4d5-4cc1-a3dd-1c09e73c3d83(en-us,PandP.20).png

Lets see the example of using Event Aggregation pattern in java script.

Suppose we have two different JavaScript pages attach with different Views/HTML page and we want to notify one if a particular event has occurred so thet on the basis of the event it can perform some action.

Here we will first create a common .js file which will have a event argument and events defined.
 var Events = {  
   OnAdded: "OnAdded",  
   OnClicked: "OnClicked",  
   OnUpdated: "OnUpdated"  
 };  
 var EventArgunments = {  
   Selectedvalue: ""  
 };  

Now on the page where we want to publish or want to subscribe the events we need to cal in the following way

 To publish event the syntax is   
  $(document).trigger(window.Events.OnClicked, window.EventArgunments);  

To Subscribe event syntax is

 To Subscribe event the syntax is   
  $(document).bind(window.Events.OnClicked, function (e, eventArgunments)  
  {  
      //code Logic goes here  
 }  

Happy Coding :)

Thursday, August 2, 2012

Microsoft finally shuts Hotmail, introduces outlook.com

Microsoft moves from Hotmail to outlook.com. We have all the features integrated in this.
 Preview below.