Home

Streams

Reactive programming is a concept for managing asynchronous events and streams. The streams are transformed from one stream into antoher using functions that are composed. The stream are immutable, i.e. cannot be changed.

Here is a small example:
var input = document.getElementById('input');
var input2 = document.getElementById('input2');
var results = document.getElementById('results');

Observable.fromEvent(input, 'keyup')
  .merge(Observable.fromEvent(input2, 'keyup'))
  .map(function(evt) {
    return evt.target.value;
  })
  .map(function(str) {
    results.value = str
  });

Keyboard events/streams from two input fields are merged into one stream. This stream is then used to update a result field.

Here is an example (make sure to show the developer console).

Compability

The concept of observables and subscribers is extremely simple. It works in all browsers.

Alternative solutions