Last active
October 16, 2020 19:03
-
-
Save joshlemer/3fd11f3aacde7dd44d764b8e1b9a9253 to your computer and use it in GitHub Desktop.
This file contains 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
// example 1: Channels | |
(async () => { | |
// make an unbuffered channel | |
const c = chan(); | |
// in separate 'thread', push 3 values into it | |
(async () => { | |
send(c, 'ping'); | |
})(); | |
const msg = rec(c); | |
console.log(msg); | |
})() | |
// example 2: Buffering | |
(async () => { | |
const messages = chan(2); | |
send(messages, 'buffered'); | |
send(messages, 'channel'); | |
console.log(rec(messages)); | |
console.log(rec(messages)); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment