Synchronet v3.19b-Win32 (install) has been released (Jan-2022).

You can donate to the Synchronet project using PayPal.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
custom:javascript:callbacks [2021/04/04 20:49] – Remove use of "called" for "invoked" Deucecustom:javascript:callbacks [2021/04/05 12:49] (current) – [Callback API] Deuce
Line 36: Line 36:
  
 ''js.addEventListener(eventName, callback)'' (returns an ID)\\ ''js.addEventListener(eventName, callback)'' (returns an ID)\\
-Installs a callback for the string ''eventName'' ''eventName'' is any string defined by the programmer.  Care should be taken to ensure the string is unique to the use case and not generic to avoid conflicting with other libraries.+Installs a user callback for the string ''eventName'' ''eventName'' is any string defined by the programmer.  Care should be taken to ensure the string is unique to the use case and not generic to avoid conflicting with other libraries.
  
 ''js.dispatchEvent(eventName[, thisObj])''\\ ''js.dispatchEvent(eventName[, thisObj])''\\
-Adds all callbacks which were installed with the specified ''eventName'' to the run queue.+Adds all user callbacks which were installed with the specified ''eventName'' to the run queue.
  
 ''js.setImmediate(callback[, thisObj])''\\ ''js.setImmediate(callback[, thisObj])''\\
Line 95: Line 95:
 <code javascript> <code javascript>
 while (js.do_callbacks && (timer_callback_count > 0 || polled_callback_count > 0 || run_queue.length > 0)) { while (js.do_callbacks && (timer_callback_count > 0 || polled_callback_count > 0 || run_queue.length > 0)) {
-        if (polled_callback_ready) {+        timeout = time_to_next_timed_event; 
 +        if (run_queue.length > 0) 
 +                timeout = 0; 
 +        poll_result = poll_callback_states(timeout); 
 +        if (poll_result.polled_callback_ready) {
                 polled_callback.call(thisObj);                 polled_callback.call(thisObj);
                 continue;                 continue;
         }         }
-        if (timed_callback_ready) {+        if (poll_result.timed_callback_ready) {
                 timed_callback.call(thisObj);                 timed_callback.call(thisObj);
                 continue;                 continue;
         }         }
-        if (run_queue.length > 0) {+        if (poll_result.run_queue.length > 0) {
                 run_queue.shift().call(thisObj);                 run_queue.shift().call(thisObj);
                 continue;                 continue;