Reputation: 99
How can I get JavaScript to act "non-blocking" like Node.js on the client? I currently have Node.js pushing me updates to the client through Socket.IO, while at the same time I have multiple AJAX calls fetching data onLoad, which seem to run in parallel, and then processing the result data, rendering it to my Knockout views, some jQuery action, etc...
But I keep running into blocking problems, for example where data is being pushed in from Node, but isn't being processed, while Javascript is processing the results of my AJAX callback results or other JS methods being run. Ideally, I would love to be able to run multiple functions in parallel.
I realize JavaScript is single threaded, but using Node.js as a model, how can I fake "non-blocking" on the client?
Upvotes: 0
Views: 187
Reputation: 12295
The HTML 5 spec allows for parallel processing using a construct called WebWorkers. You can find details on this specification at the following links (listed in what I believe to be order of usefulness):
Upvotes: 1