Skip to content

Instantly share code, notes, and snippets.

@avnersorek
Created October 9, 2015 07:11
Show Gist options
  • Save avnersorek/ee6e97778bf6502770d7 to your computer and use it in GitHub Desktop.
Save avnersorek/ee6e97778bf6502770d7 to your computer and use it in GitHub Desktop.
import {go, chan, take, put} from 'js-csp';
let channel = chan();
go(function* () {
const text = yield take(ch);
console.log('A > RECEIVED:', text);
});
go(function* () {
const text = yield take(ch);
console.log('B > RECEIVED:', text);
});
go(function* () {
const text = 'dog'
console.log('C > SENDING:', text);
yield put(ch, text);
});
// terminal output:
//
// => C > SENDING: dog
// => A > RECEIVED: dog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment