event-sinks

create a set of sinks for events

event-sinks

create a set of sinks for events

This allows you to create an event emitter, and pass a set of sinks to someone else. Somebody else can invoke your sinks and send values to your event emitter.

This allows you to write decoupled interfaces.

var EventSinks = require("event-sinks")
 
var inputs = EventSinks(["foo", "bar"])
var emitter = inputs.emitter
var sinks = inputs.sinks
 
emitter.on('foo', function (ev) {
  console.log('foo', ev)
})
emitter.on('bar', function (ev) {
  console.log('bar', ev)
})
 
sinks.foo.write('hello')
sinks.bar.write('bar')
var EventSinks = require("event-sinks/geval")
 
var inputs = EventSinks(["foo", "bar"])
var events = inputs.events
var sinks = inputs.sinks
 
events.foo(function (ev) {
  console.log('foo', ev)
})
events.bar(function (ev) {
  console.log('bar', ev)
})
 
sinks.foo.write('hello')
sinks.bar.write('bar')

npm install event-sinks

  • Raynos