dojo.subscribe
<script src="../../js/dojo.js"></script>
defined in dojo/_base/connect.js
Attach a listener to a named topic. The listener function is invoked whenever the named topic is published (see: dojo.publish). Returns a handle which is needed to unsubscribe this listener.
parameter | type | description |
---|---|---|
topic | String | |
context | Object | Scope in which method will be invoked, or null for default scope. |
method | String|Function | The name of a function in context, or a function reference. This is the function that is invoked when topic is published. |
Examples
Example 1
dojo.subscribe("alerts", null, function(caption, message){ alert(caption + "\n" + message); };
dojo.publish("alerts", [ "read this", "hello world" ]);