Hacker News new | comments | show | ask | jobs | submit login

Use recursion. Fixed:

  asynchronousCache.get("id:3244", function doThing(err, myThing) {
    if (myThing === null) {
      asynchronousDB.query("SELECT * from something WHERE id = 3244", function(err, myThing) {
  		// We now have a thing from DB, do something with result
  		doThing(err, myThing);
      });

      return;
    } else if(err !== null) {
  	// Handle error.
  	return;
    }

  // We have a thing.
  });



Were you implying that your solution was simpler?




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: