For instance take the following code:
getThing = (thing_id, cb_success, cb_error) ->
model.findById thing_id,
(error, thing) ->
if error || !thing
cb_error "error"
else
cb_success thing
And then to call the function
getThing thing_id
, (thing) ->
console.log "Found a thing!"
, (error)
console.log" Uh oh..."
If I'm passing multiple callbacks, none of which are guaranteed to be called, how can I structure await/defer for this case? Or do I need to totally rethink my code to only provide a single callback and then evaluate the presence of an error within that?