JS-Interpreter Async Demo

Asynchronous function calls in the real world can be wrapped to appear synchronous to code running in the JS-Interpreter. The example below (see this page's source) creates a getXhr function that fetches a URL and returns the content.

This function is defined using createAsyncFunction during initialization. When called, the interpreter is paused until the callback occurs. During this paused state, step and run will both do nothing, returning true to indicate that the program still has code to execute.

Click Parse, then either click Step repeatedly, or click Run once. Open your browser's console for errors.


Back to the JS-Interpreter documentation.