DEV Community

Discussion on: What is reactive and stream programming?

Collapse
 
fribentech profile image
Friben Tech

I'm not fully understanding what stream programming is. So stream programming is when there are multiple inputs connected to an output stream which then sends the information back through the multiple inputs? Correct me where I'm wrong.

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

It might be easier to visualize as single-input to output scenario. I'll use audio since it's easy to understand as a stream.

You have an amplify function that makes the sound longer. You plugin the input stream to this "function" and it's output is a louder sound. The data is "streamed": input continually reachs this function and is continually output by the function.

For the two input case you can have a mix function that combines them and produces one output.

This is a form of reactive programming since you still have an output that automatically reflects the state of the input. Just in this case the input is continually changing.

For example, you might have a UI which connects to a CD player as follows:

cd_data -> decoder -> amplify -> fft -> graph_display

The graph_display is a reactive control that continually updates it's appearance based on the output of fft, which in turn connects backwards until it reaches the raw cd_data.