GraftJS / jschan

JavaScript port of libchan based around streams
MIT License
157 stars 9 forks source link

Create channels from the global jsChan object #21

Closed mcollina closed 9 years ago

mcollina commented 9 years ago

Currently to create a return channel we use:

var jschan  = require('jschan');
var session = jschan.memorySession();
var chan = session.createWriteChannel();
var ret  = chan.createReadChannel();

chan.write( { hello: 'world, ret: ret } );

However it will be much simpler to have:


var jschan  = require('jschan');
var session = jschan.memorySession();
var chan = session.writeChannel(); // shorter
var ret  = jschan.readChannel(); // simpler, channels are derived from the top-level objects, and then passed through. 

chan.write( { hello: 'world, ret: ret } );
mcollina commented 9 years ago

See https://github.com/GraftJS/graft/commit/a9511f406f714e6cfd6543e6b2003b101430bc32#commitcomment-7514435

mcollina commented 9 years ago

I think this is not needed anymore, due to the fact that we can always create a memorySession() and create channels from there, and these will be auto-piped when passed through other sessions.