understandinges6 asynch task runner

15 views
Skip to first unread message

wd

unread,
Jan 15, 2020, 12:49:50 PM1/15/20
to Zakas Books
Hi Nicholas,
on page 162 you define your callback as

Code hier eingeben...

function (err, data) {
  if (err) {
    result = task.throw(err);
    return;
  }
 
  result = task.next(data);
  step();
}


would the following be a viable alternative?

function (err, data) {
  result = err ? task.throw(err) : task.next(data) || {done:true};
  step();
}


Best regards, Will

Nicholas Zakas

unread,
Jan 16, 2020, 4:00:16 PM1/16/20
to zakas...@googlegroups.com
Hi Will,

In the case of an error you wouldn’t want to call step(), so the two functions are not equivalent. 



--
You received this message because you are subscribed to the Google Groups "Zakas Books" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zakasbooks+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zakasbooks/15a34b1d-cedb-48e7-bd85-ba3645c1f6c2%40googlegroups.com.
--

______________________________
Nicholas C. Zakas
@slicknet

Author, Principles of Object-Oriented JavaScript
Reply all
Reply to author
Forward
0 new messages