You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.5 KiB
40 lines
1.5 KiB
4 years ago
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
var ConnectableObservable_1 = require("../observable/ConnectableObservable");
|
||
|
function multicast(subjectOrSubjectFactory, selector) {
|
||
|
return function multicastOperatorFunction(source) {
|
||
|
var subjectFactory;
|
||
|
if (typeof subjectOrSubjectFactory === 'function') {
|
||
|
subjectFactory = subjectOrSubjectFactory;
|
||
|
}
|
||
|
else {
|
||
|
subjectFactory = function subjectFactory() {
|
||
|
return subjectOrSubjectFactory;
|
||
|
};
|
||
|
}
|
||
|
if (typeof selector === 'function') {
|
||
|
return source.lift(new MulticastOperator(subjectFactory, selector));
|
||
|
}
|
||
|
var connectable = Object.create(source, ConnectableObservable_1.connectableObservableDescriptor);
|
||
|
connectable.source = source;
|
||
|
connectable.subjectFactory = subjectFactory;
|
||
|
return connectable;
|
||
|
};
|
||
|
}
|
||
|
exports.multicast = multicast;
|
||
|
var MulticastOperator = (function () {
|
||
|
function MulticastOperator(subjectFactory, selector) {
|
||
|
this.subjectFactory = subjectFactory;
|
||
|
this.selector = selector;
|
||
|
}
|
||
|
MulticastOperator.prototype.call = function (subscriber, source) {
|
||
|
var selector = this.selector;
|
||
|
var subject = this.subjectFactory();
|
||
|
var subscription = selector(subject).subscribe(subscriber);
|
||
|
subscription.add(source.subscribe(subject));
|
||
|
return subscription;
|
||
|
};
|
||
|
return MulticastOperator;
|
||
|
}());
|
||
|
exports.MulticastOperator = MulticastOperator;
|
||
|
//# sourceMappingURL=multicast.js.map
|