Learning Dojo — 3.3 Asynchronous Programming

Handling dom events

  a.Define the event handler

        function alertSomeEvent(){

  b.Connect some event to the handler

   	function connect(){
  	    dojo.connect(dojo.byId("someButton"),"click", alertSomeEvent);  	   

  c.Register this connection when dom tree initialization is done



Handling user-defined events

   It’s similar with handling dom events, only that the events here user-defined functions

Publish-Subcribe Framework

    <!--I'm going to publish this topic when I am clicked -->
    <button onclick="javascript:dojo.publish('someTopic')">publish</button>

    //A topic handler will handle this topic
     dojo.subscribe("someTopic", handleSomeTopic);

    //And it will handle the topic like this,
       	function handleSomeTopic(){
  	  alert("some topic is published");


Advanced Topic

   Do the research by yourself if you need them

    a.Bubbling/Capturing  (Event Propagation)

    b.dojo.Deferred  (multi-thread programming)

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.