Long running processes and JavaScript

Events like mouse clicks and keystrokes are handled in a single dedicated thread.

If the handling JavaScript, which also runs in its own thread, is unresponsive, the browser remains responsive, but eventually willl inform the user of the problem and give them the option of cancelling the handler!

This means that long running client side code cannot be executed without implementing a continuation style approach.

Example 1
could be replaced with:
Example 2


This is horrible. However, the javascript library Narrative enables blocking capabilities for asynchronous event callbacks. This makes asynchronous code more readable.

So, it will convert the following code into Example 2:


Fortunately, it is rare that the client code should ever have to execute long processes.

Posted in Labels: |

0 comments: