3 ms·
I guess I just don't think it's a serious issue. I've found that often when I have an "issue" it's more so my design lacking not the tool (javascript) itself.
by rubyn00bie 13y ago
I guess I just don't think it's a serious issue. I've found that often when I have an "issue" it's more so my design lacking not the tool (javascript) itself.
- ilaksh 13y agoWhat would the code look like for my example using futures in JavaScript?
- TheZenPsycho 13y agofs.readFile("person.json") .then(function(e, personJson) { var person = JSON.parse(personJson); return myDB.query("lastname", person.name); }) .then(function(matched) { return msgQueue.push(JSON.stringify(matchesLastname)); }) .then(function(id) { log.info("Message sent to queue: " + id); });
- ilaksh 13y agoThat's part of it. What about creating the promises?
- TheZenPsycho 13y agothat's in there, with the assumption that you're using the promises based node.js api, but if you aren't, and you're using Q, that part looks like this var readFile = Q.denodeify(FS.readFile); which doesn't create the promise. it just wraps the readFile method so that it returns a promise when you call it.