channel.md 1.1 KB

Channel independence

We should be able to return a disconnected channel that would connect on data set i.e

	// EventualContext
	var ectx = eventual.createContext(); // Creates a context that can be destroyed
	ectx
		.channel('named')
		.on('something')

TODO

  • Known bug/Idea - if we request a channel and emit it will only send in this channel context Maybe we can create channels for listen purpose only, and ctx for broadcasting? Maybe expose broadcast and leave the possibility for single communication, as:

```javascript

var ctx1=eventual.createContext();
var ctx2 = eventual.createContext();

var hellochn = ctx1.channel('hello')
hellochn.on('msg',() => { console.log('hello ctx1'); };

// Same thing but for context2
ctx2.on('hello:msg', () => { console.log("Hello from ctx2"); });

// Now:

// Only it would call only local, 'hello ct1' would be printed
hellochn.emit('msg');
// (not implementd) IDEA: It would print, 'hello ctx1', and 'Hello from ctx2'
hellochb.broadcast('msg');          // channel prefixing, It would send 'hello:msg' 

````