Last active
October 17, 2017 20:30
-
-
Save nanot1m/6252e732667f4048790efd47198258dd to your computer and use it in GitHub Desktop.
Push iterator
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
async function* MessagesGenerator() { | |
try { | |
while (true) { | |
// listenToNewMessages: (message => void) => void | |
yield await new Promise(listenToNewMessages); | |
} | |
} | |
} | |
const messages = MessagesGenerator() | |
for await (let message of messages)) { | |
console.log(message) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment