Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. module.exports = function fetchRecords() {
  2. return openConnection()
  3. .then(fetchRecords)
  4. .then(groupById)
  5. .catch(rethrow)
  6. .done(closeConnection);
  7. }
  8.  
  9. function closeConnection(result) {
  10. releaseConnection();
  11. return result;
  12. }
  13.  
  14. resource.fetchRecords().then(/*do something else*/);
  15.  
  16. resource
  17. .openConnection()
  18. .then(resource.fetchRecords)
  19. .then(/*do something else*/)
  20. .catch(/*..*/)
  21. .end(resource.close)
  22.  
  23. module.exports = function fetchRecords() {
  24. return openConnection()
  25. .then(fetchRecords)
  26. .then(groupById)
  27. .then(closeConnection)
  28. .catch(rethrow);
  29. }
  30.  
  31. module.exports = function fetchRecords() {
  32. return openConnection()
  33. .then(fetchRecords)
  34. .then(groupById)
  35. .catch(rethrow)
  36. .finally(closeConnection);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement