This is RxJS v 4. Find the latest version here
Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
invocation. For specializations with fixed subject types, see publish
, share
, publishValue
, shareValue
, publishLast
, replay
, and shareReplay
.
subjectSelector
(Function
): Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.subject
(Subject): Subject to push source elements into.[selector]
(Function
): Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only ifsubjectSelector
is provided.
(Observable
): An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
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();
// => Next: 0
// => Next: 0
// => Next: 1
// => Next: 1
// => Next: 2
// => Next: 2
// => Completed
File:
Dist:
Prerequisites:
- If using
rx.binding.js
NPM Packages:
NuGet Packages:
Unit Tests: