Tagged Questions
4
votes
2answers
2k views
Async, callbacks, and closures — am I doing it right?
After having spent a month or two trying to learn JavaScript, especially functional programming, async, and closures, I finally get it. But I don't know if I'm writing elegant code... Specifically, ...
3
votes
1answer
765 views
Node.js Async Callback Hell
Attempting to create a final array with data pulled from 3 functions. The first two functions have all the data but then the 3rd function needs to run looping through one of the fields from function 2 ...
3
votes
1answer
290 views
Asynchronous lightweight JSON API
I am writing a lightweight JSON API, and I come from a PHP background, so I have some questions/reviews about async node.js code.
This is my code so far:
main.js
...
3
votes
0answers
318 views
Optimizing async joins for mongodb (mongoose) using async.js
I'm building a media viewer web app for a kiosk in node that uses data in mongo. To render the viewer, it gathers together all the Asset objects (representing video files), each of which belong to a ...
2
votes
1answer
223 views
Limiting Q promise concurrency in JavaScript
I wrote a helper to limit Q promise concurrency.
If I have a promise-returning function promiseSomething, writing
...
2
votes
1answer
62 views
nodejs grunt plugin using async module
I'm looking for some code review of my usage of async. Mainly why this does not work without the done = this.async() method and why I don't have to invoke 'done()' ...
2
votes
1answer
70 views
Cleaning up nested promises in Cloud function
I am writing the Cloud function for Parse whose purpose is to update my database with a provided array of data objects. The main problem are the nested promises, which doesn't look right. Any help ...
2
votes
1answer
218 views
Am I using Q the right way or is there a better way to do what I'm doing?
I'm using Q to flatten out some callbacks in my unit tests and return a promise to mocha (which knows to wait until the promise is resolved before running the next test).
Originally I had this code:
...
1
vote
2answers
185 views
A server response written in node/express/mongodb: does this look right?
This is my very very very first attempt to write anything meaningful in node. The client side is a simple form that has login, workspace, and simply saves them onto the database. It would have been a ...
1
vote
1answer
153 views
Best way to handle the error in async node
To catch errors, I have written if-else blocks in every function which looks bad. Please suggest a better way to handle errors in async node.
...
1
vote
1answer
227 views
Is this factory method a good approach?
We are beginning to learn Node.js and we are not always sure if we do it the right way. We have a strong object oriented background so the adoption is not always easy. Right now we implemented a ...
1
vote
1answer
910 views
Simple Telnet Chat Server nodejs (correct way to write programs in node.js (asynchronous programming model))
I am new to node.js and asynchronous programming and this is my first small project to learn it. I have written a small Telnet Chat server and the program works but I want to know if this is the ...
1
vote
1answer
91 views
Node.js/javascript: synchronizing async tasks
Yes, I know there are plenty of libraries to get this done (Q, step, async), but only for learning I'm wondering if the following code is ok and usable or have major drawbacks and it is only usable at ...
1
vote
1answer
1k views
Node.js Nested Callbacks, multiple requests
I'm making requests to Parse.com to 3 different objects that are needed to render a View.
I'd like to know what's the general/best approach in cases like these in which there are multiple requests ...
0
votes
2answers
80 views
Promises and chained calls
I've realized JS callback hell and I started looking into Promises libraries.
After reading some articles I decided to start with BluebirdJS. I didn't realise how to properly use them yet, because ...