I am new to asynchronis programming and think I understand the concept: What is the difference between synchronous and asynchronous programming (in node.js)
I am looking at a project that uses a websockets data feed: http://pastebin.com/dMX7mZE0
var autobahn = require('autobahn');
var wsuri = "wss://api.poloniex.com";
var connection = new autobahn.Connection({
url: wsuri,
realm: "realm1"
});
connection.onopen = function (session) {
function marketEvent (args,kwargs) {
console.log(args);
}
function tickerEvent (args,kwargs) {
console.log(args);
}
function trollboxEvent (args,kwargs) {
console.log(args);
}
session.subscribe('BTC_XMR', marketEvent);
session.subscribe('ticker', tickerEvent);
session.subscribe('trollbox', trollboxEvent);
}
connection.onclose = function () {
console.log("Websocket connection closed");
}
connection.open();
In the example code there are three functions that return data however I am unsure of how to have my code respond to the data returned as these three are continually running simultaneously.
Should I place code to be executed directly within the class methods themselves or would it be better to have the class methods dump their data into a database and then have my code continually reading the database data and acting accordingly?
Thanks and apologies for the noob qn.