I have a single-page application in Node.js
, React
, Express
and Socket.IO
whose dataflow is divided as follows:
A C# server application serves the feed.js
data through Socket.IO
. feed.js
in turn is also responsible for the turning that data around (after updating datastructures for correct presentation to app.js) and serving it to app.js
to display in the browser.
// Handle real-time incoming messages from c# clients.
socket.on('data', function (data) {
broadcast(data, socket);
});
function broadcast(message, sender) {
//process.stdout.write("Full message " + message.toString() + "\n");
//...To app.js
onChangeHandler(stock.symbol, 'stock', stock);
In this situation, under real-time load, the browser sometimes becomes unresponsive not so much to the data, but to view-like commands that affect the display. In other words, I can still see the data updating, but mouse-clicks on the browser don't get handled interactively.
The normal reaction as a "desktop developer" is to keep computation (model) separated from view by creating extra computation threads - with the view already running on its own thread. However, I have read that Node.js (and the supporting cast) is single threaded on purpose. Doesn't seem as if Socket.IO
has that limitation though.
Wondering what the idiom in Node.js etc is to write real-time applications that are responsive on a web browser both in data and in GUI interactivity. An example or a link to one would help.