The following methods are supported for a stream creation:
- Tix.stream(g(sink)) - Manually defining streams. The generator function
greceives a sink object with three methods:- sink.value(value) - For sending value
valueinto to stream. - sink.error(value) - For sending error into to stream.
- sink.end(value) - For signaling that the stream should end.
- sink.value(value) - For sending value
- Tix.fromCallback(g(cb)) - Create a stream from a "regular" callback (e.g.
cb(val)) - Tix.fromNodeCallback(g(cb)) - Create a stream from a "node-style" callback (e.g.
cb(err, val)) - Tix.fromPoll(interval,g) - Create a stream comprised of events generated by function
geveryintervalmilliseconds. - Tix.fromEvent(target, eventName, transform) - Create a stream events out of an event emitter (
addEventListener,onandbindare supported) - Tix.sequentially(interval, sequence) - Create a streams based on sequenced values (repeated infinitely).
- Tix.later(interval, value) - Creatie a one value stream following an interval of
intervalmilliseconds. - Tix.interval(interval, value) - Creating a recurring constant value stream. Each event is
intervalmilliseconds apart.
The following methods are available on every stream, and allow multiple transformation to be applied to it:
- take(n) - Takes n values, then end stream.
- first() - Takes first value, then end stream.
- last() - Takes very last value before a stream ends.
- map(mapper) - Applies a
mapperfunction to stream values. - filter(filter) - Applies a
filterfunction to stream values, filters stream events accordingly. - merge(streams) - Merges one or multiple streams.
- delay(milliseconds) - Adds a constant delay to values.
- scan(scanFunctor, seed) - Scans stream value-pairs, and applies a functor to them. If a seed is provided, it is used as the first value, otherwise the scan will beginning running starting the second value.
- onValue(listener) - Registers
listenerfor receiving a stream's values. - offValue(listener) - Unregisters
listenerfor receiving a stream's values. - onError(listener) - Registers
listenerfor receiving a stream's errors. - offError(listener) - Unregisters
listenerfor receiving a stream's errors. - onEnd(listener) - Registers
listenerfor receiving a stream's end. - offEnd(listener) - Unregisters
listenerfor receiving a stream's end. - subscribe(subscriber) - Registeres
subscriberfor receiving raw Tix events of all types (value/error/end). - unsubscribe - Unregisteres
subscriberfor receiving raw Tix events of all types (value/error/end).