Help me to understand my own code

87 views
Skip to first unread message

Alexey Slaykovsky

unread,
Nov 16, 2014, 8:27:32 AM11/16/14
to nod...@googlegroups.com
Hello, guys! I need help.
I wrote a code which takes one object, another object and then changes values of that second object.
And this code is nice for me. It makes this transformation async and nonblocking. But! I need my output (https://gist.github.com/slaykovsky/ac72e85a116617fb761d) only once at the end.
And I don't know how to do that. I posted question like that one on stackoverflow, but that one is dead.
Help me please. I really need to do that.

Alexey Slaykovsky

unread,
Nov 16, 2014, 10:51:37 AM11/16/14
to nod...@googlegroups.com
Thanks to Alex Kocharin!
It's working like a charm. Look at that gist https://gist.github.com/rlidwka/8a375c02042eaf0b05b0

Alex Kocharin

unread,
Nov 16, 2014, 11:15:38 AM11/16/14
to nod...@googlegroups.com, ale...@slaykovsky.com
 
So, the only issue is that your callback is called multiple times, right?
 
In that case you can make a counter, which you increase when you're creating callback and decrease when your callback is called. If it's zero again, the work is finished.
 
Here is a gist code which'll hopefully answer this:
 
 
// copying message to personal email, because mailing list is too slow because of pre-moderation nowadays, and I suppose you want the answer quickly
 
16.11.2014, 17:52, "Alexey Slaykovsky" <ale...@slaykovsky.com>:
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/f0caceea-a1d6-4de3-9b80-81efefb5006f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages