Created
          November 24, 2016 17:41 
        
      - 
      
- 
        Save offero/bbbd3181f0f904ed5ffa1f0118b8a73b to your computer and use it in GitHub Desktop. 
    Promise in a callback
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function doThingThatAcceptsCallback(arg1, callback) { | |
| doThingThatReturnsAPromise(arg1) | |
| .then(function resolved(result) { | |
| callback(null, result); | |
| }) | |
| .catch(function rejected(error) { | |
| callback(error); | |
| }); | |
| } | |
| // same with es6 functions | |
| function doThingThatAcceptsCallbackES6(arg1, callback) { | |
| doThingThatReturnsAPromise(arg1) | |
| .then(result => callback(null, result)) | |
| .catch(error => callback(error); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment