The above operators are available in the following packages:
rx.all.js
rx.all.compat.js
rx.binding.js (requires either rx.js or rx.compat.js)
rx.lite.js
rx.lite.compat.js
RxJS also has a multicast operator which operates on an ordinary Observable,
multicasts that Observable by means of a particular Subject that you specify, applies a
transformative function to each emission, and then emits those transformed values as its own
ordinary Observable sequence. Each subscription to this new Observable will trigger a
new subscription to the underlying multicast Observable.
Sample Code
var subject = new Rx.Subject();
var source = Rx.Observable.range(0, 3)
.multicast(subject);
var observer = Rx.Observer.create(
function (x) { console.log('Next: ' + x); },
function (err) { console.log('Error: ' + err); },
function () { console.log('Completed'); }
);
var subscription = source.subscribe(observer);
subject.subscribe(observer);
var connected = source.connect();
subscription.dispose();
The multicast operator is available in the following packages:
rx.all.js
rx.all.compat.js
rx.binding.js (requires either rx.lite.js or rx.compat.js)
rx.lite.js
rx.lite.compat.js
There is also a let operator (the alias letBind is available for
browsers such as Internet Explorer before IE9 where “let” is
forbidden). It is similar to multicast but does not multicast the underlying
Observable through a Subject:
Sample Code
var obs = Rx.Observable.range(1, 3);
var source = obs.let(function (o) { return o.concat(o); });
var subscription = source.subscribe(
function (x) { console.log('Next: ' + x); },
function (err) { console.log('Error: ' + err); },
function () { console.log('Completed'); });
var subscription = source.subscribe(
function (x) { console.log('Next: ' + x); },
function (err) { console.log('Error: ' + err); },
function () { console.log('Completed'); });