Guest User

Untitled

a guest
Aug 16th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. write data1
  2. write data2
  3. write data3
  4.  
  5. ... after some delay
  6.  
  7. response for data1
  8. response for data2
  9. response for data3
  10.  
  11. async function sendData(data) {
  12. await streamObj.data()
  13. }
  14.  
  15. console.log('reponse1', await sendData('data1'));
  16. console.log('reponse2', await sendData('data2'));
  17. console.log('reponse3', await sendData('data3'));
  18.  
  19. console.log(await Promise.all(sendData('data1'), sendData('data2'), sendData('data3')));
  20. // should logs: [ 'response1', 'response2', 'response3' ]
Add Comment
Please, Sign In to add comment