Permalink
Browse files

Added comments

  • Loading branch information...
1 parent a2109e9 commit f8840b0b40cfd8bbc86ba30911b5f6ab5f3ac486 @rgr-myrg committed Dec 23, 2011
Showing with 20 additions and 1 deletion.
  1. +20 −1 examples/pubsub.html
View
@@ -7,9 +7,9 @@
</style>
<script type="text/javascript" src="devshop-full.js"></script>
<script type="text/javascript">
+ //Subscriber must have onRegister method that returns notification interests
var Echo={
onRegister: function(){
- console.log('onRegister');
return {
ON_KEYUP: this.onKeyUp
};
@@ -45,9 +45,11 @@
document.getElementById('vertical').innerHTML=msg;
}
};
+ //Define events for your app
var Events={
ON_KEYUP: new DevShop.EventSignal
};
+ //Create an instance of Publisher
var UI=new DevShop.Publisher();
UI.registerEvents(Events);
UI.registerSubscriber(Echo);
@@ -57,6 +59,23 @@
var data = document.getElementById('box').value;
this.notify(Events.ON_KEYUP, data);
};
+
+ //Alternate way of 'extending' the publisher example:
+ var UIx=new DevShop.SingletonFactory({
+ extend: DevShop.Publisher,
+ instance:function(){
+ this.onKeyUp=function(){
+ var data = document.getElementById('box').value;
+ this.notify(Events.ON_KEYUP, data);
+ };
+ this.initialize=function(){
+ this.registerEvents(Events);
+ this.registerSubscriber(Echo);
+ this.registerSubscriber(Mirror);
+ this.registerSubscriber(Vertical);
+ };
+ }
+ });
</script>
</head>
<body>

0 comments on commit f8840b0

Please sign in to comment.