1. XmlStream in your example emits other events than 'data'
2. the endElement handler, is this the right signature? please check the
doc/code of the XmlStream on this point
besides this points i guess this would work IF XmlStream implements the
node core Readable:
var xml = new XmlStream(response, 'utf8');
xml.on('endElement: endmarker ', writetoDB);
function writetoDB(input) {
console.log('i want to arrive here first upon receipt of the xml
endmarker');
db.create(input, function(err){
if(err) {
// do error handling here
return
}
console.log('create complete');
console.log('action this second');
xml.resume()
});
}
Am Dienstag, 10. September 2013 23:31:00 UTC+2 schrieb HungryHippo:
>
> sorry, i'm such a noob, i'm just getting more confused. the working
> version of my code returns from the endmarker too soon, it doesn't wait for
> the db.create to complete which is what i need to slow down the reads from
> overwhelming the slow writes.
>
> Here in a nutshell is my revised code (which doesn't compile :-( but
> hopefully it better confers what I'm trying to achieve in terms of code
> execution order....
>
> 1) endmarker event received
> 2) writetoDB
> 3) db.create
> 4) db.create completes
> 5 writetoDB completes
> 6 return from endmarker
>
>
>
> var xml = new XmlStream(response, 'utf8');
>
> xml.on('endElement: endmarker ', function writetoDB(input,
> callback){
> console.log('i want to return from here last after calling
> 'writetoDB' and completing db.create');
> });
>
> function writetoDB(input, callback) {
> console.log('i want to arrive here first upon receipt of the
> xml endmarker');
> db.create(input, function(){
> console.log('create complete');
> console.log('action this second');
> callback();
> });
> }
>
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.