Skip to content

Instantly share code, notes, and snippets.

@mindspank
Created December 2, 2015 01:29
Show Gist options
  • Save mindspank/ed24854e09b7eae3c57e to your computer and use it in GitHub Desktop.
Save mindspank/ed24854e09b7eae3c57e to your computer and use it in GitHub Desktop.
loop apps with qsocks
var qsocks = require('qsocks');
var Promise = require('bluebird');
qsocks.Connect()
.then(function(global) {
return global.getDocList();
})
.then(function(doclist) {
//Map over doclist, limit to 3 connection at a time to not choke the available sockets
return Promise.map(doclist, function(d) {
return qsocks.Connect({appname: d.qDocId})
.then(function(global) {
return global.openDoc(d.qDocId)
})
.then(function(app) {
//Do something with app, in this case list all objects.
return app.getAllInfos();
})
}, {concurrency: 3})
})
.then(function(props) {
console.log(props)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment