芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/app.optimyar.com/backend/node_modules/rxjs/src/internal/operators/multicast.ts
import { Subject } from '../Subject'; import { Operator } from '../Operator'; import { Subscriber } from '../Subscriber'; import { Observable } from '../Observable'; import { ConnectableObservable, connectableObservableDescriptor } from '../observable/ConnectableObservable'; import { MonoTypeOperatorFunction, OperatorFunction, UnaryFunction, ObservedValueOf, ObservableInput } from '../types'; /* tslint:disable:max-line-length */ export function multicast
(subject: Subject
): UnaryFunction
, ConnectableObservable
>; export function multicast
>(subject: Subject
, selector: (shared: Observable
) => O): UnaryFunction
, ConnectableObservable
>>; export function multicast
(subjectFactory: (this: Observable
) => Subject
): UnaryFunction
, ConnectableObservable
>; export function multicast
>(SubjectFactory: (this: Observable
) => Subject
, selector: (shared: Observable
) => O): OperatorFunction
>; /* tslint:enable:max-line-length */ /** * Returns an Observable that emits the results of invoking a specified selector on items * emitted by a ConnectableObservable that shares a single subscription to the underlying stream. * *  * * @param {Function|Subject} subjectOrSubjectFactory - Factory function to create an intermediate subject through * which the source sequence's elements will be multicast to the selector function * or Subject to push source elements into. * @param {Function} [selector] - Optional selector function that can use the multicasted source stream * as many times as needed, without causing multiple subscriptions to the source stream. * Subscribers to the given source will receive all notifications of the source from the * time of the subscription forward. * @return {Observable} An Observable that emits the results of invoking the selector * on the items emitted by a `ConnectableObservable` that shares a single subscription to * the underlying stream. * @method multicast * @owner Observable */ export function multicast
(subjectOrSubjectFactory: Subject
| (() => Subject
), selector?: (source: Observable
) => Observable
): OperatorFunction
{ return function multicastOperatorFunction(source: Observable
): Observable
{ let subjectFactory: () => Subject
; if (typeof subjectOrSubjectFactory === 'function') { subjectFactory = <() => Subject
>subjectOrSubjectFactory; } else { subjectFactory = function subjectFactory() { return
>subjectOrSubjectFactory; }; } if (typeof selector === 'function') { return source.lift(new MulticastOperator(subjectFactory, selector)); } const connectable: any = Object.create(source, connectableObservableDescriptor); connectable.source = source; connectable.subjectFactory = subjectFactory; return
> connectable; }; } export class MulticastOperator
implements Operator
{ constructor(private subjectFactory: () => Subject
, private selector: (source: Observable
) => Observable
) { } call(subscriber: Subscriber
, source: any): any { const { selector } = this; const subject = this.subjectFactory(); const subscription = selector(subject).subscribe(subscriber); subscription.add(source.subscribe(subject)); return subscription; } }