snsary.streams
A Stream is an Output and a Source that provides some kind of additional functionality over connecting Sources to Outputs directly. All Sensors expose a stream of their Readings e.g. MockSensor().stream returns an AsyncStream to cope with flakey Outputs.
Streams make it easy to subscribe multiple Outputs with into:
# same as calling "subscribe" for each
stream.into(MockOutput(), MockOutput())
Any Stream can also be wrapped in a Filter function e.g.
# only output readings for sensor "foo"
stream.apply(Filter.sensor_name('foo')).into(MockOutput())
# only output readings called "a", etc.
# convenience shortcut method for "apply"
stream.filter_names('a', 'b', 'c').subscribe(MockOutput())
A stream can actually be used to apply any one-to-many function to the readings that pass through it. For example, to average the distinct readings received in a window:
# outputs an average value every 3 seconds
# for each distinct sensor / reading name;
# convenience shortcut method for "apply"
stream.average(seconds=3).into(MockOutput())