a bit of
a functional-reactive approach to flow-based programming
make chains of functions, a-la max/msp, puredata, vvvv, etc, to program with streaming sources of data
update processing/output functions without disturbing your source streams.
components
components are attached together to process streams.
components are made out of a function. general pattern:
var c = console
the component's consturctor takes an error callback. you can set the component's function by calling its update
method.
there are three types of components:
origin
origin's functions take nothing
they reutrn a list of [ [ emitter, 'event' ] ..]
{ // port is an EventEmitter port = socket = // we want to make a stream of its 'data' events return port 'data' socket 'event' } var o = console
transform
transform function's take an arbitrary number of streams, and return a list of streams
{ // return a stream of fft'd buffers return deviceStream socketStream } var t = console
endpoints
endpoint functions return a list of functions.
the functions handle values from inputs stream
{ // endpoints setup logic midiServerstart // return handle(), and, optionally, a taredown () function return { midiServer; midiServer; } } var e = console
optionally, endpoint functions can return a taredown()
method, which gets triggered when a new update() function is passed through
use it for, e.g., removing divs so that you can re-add them.
{ // endpoints setup logic midiServerstart // return handle(), and, optionally, a taredown () function return handlers: { midiServer } // taredown { midiServer }
attaching components together
var abitof = // make componentsvar o = someOriginFnvar t = someTransformFnvar e = someEndpointFn // attach them togethero
api
origin
update(originFn)
attach(someDownstreamComponent)
transform
update(transformFn)
attach(someDownstreamComponent)
endpoint
update(transformFn)
NOTE: you can't attach anything to endpoints. nothing can be downstream from an endpoint.