Skip to content

Instantly share code, notes, and snippets.

@ubiquitousthey
Created September 6, 2012 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ubiquitousthey/3659297 to your computer and use it in GitHub Desktop.
Save ubiquitousthey/3659297 to your computer and use it in GitHub Desktop.
Deferred Usage with node
//Usage
DeferredPromise<MedicalRecord> mrDef = mgr.get(MedicalRecord.class, mrid);
DeferredPromise<Problem> pDef = mgr.get(Problem.class, pid);
// Implicit Error Handling (Red Bar)
Deferred.when(mrDef, pDef).then(new EmrDeferredCommand(){
@Override public void doOnSuccess(){
MedicalRecord mr = mrDef.getResult();
Problem p = pDef.getResult();
// yadda yadda yadda
}
})
// Explicit Error Handling (Do we ever do this?)
Deferred.when(mrDef, pDef).then(new DeferredCommand(){
@Override public void doOnSuccess(){
MedicalRecord mr = mrDef.getResult();
Problem p = pDef.getResult();
// yadda yadda yadda
}
@Override public void doOnFailure(List<Throwable> exceptions){
//Log stuff
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment