Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. // Callback pattern
  2.  
  3. function reportToMotherShip(callback: GenericAsyncCallback<Error, never>) {
  4. console.log(`Sending results to the mothership...`);
  5.  
  6. asyncApi((error, result) => {
  7. if (error) {
  8. console.error(`Failed to get results, cancelling message.`);
  9. callback(error);
  10. } else {
  11. asyncDoSomethingWithResult(result, (error, message) => {
  12. if (error) {
  13. console.error(`Failed to send results to the mothership.`)
  14. callback(error);
  15. } else {
  16. console.log(`Message from the mothership: ${message}`);
  17. callback(null);
  18. }
  19. })
  20. }
  21. })
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement