Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 16th, 2012  |  syntax: None  |  size: 0.43 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Example 1
  2. mediator.name = 'Doug';
  3. mediator.subscribe('nameChange', function(arg){
  4.      console.log(this.name);
  5.      this.name = arg;
  6.      console.log(this.name);
  7. });
  8.  
  9. mediator.publish('nameChange', 'Jorn');
  10.  
  11.  
  12. // Example 2
  13. var obj = { name : 'John' };
  14. mediator.installTo(obj);
  15.  
  16. obj.subscribe('nameChange', function(arg){
  17.      console.log(this.name);
  18.      this.name = arg;
  19.      console.log(this.name);
  20. });
  21.  
  22. obj.publish('nameChange', 'Sam');