1 line
7.5 KiB
Plaintext
1 line
7.5 KiB
Plaintext
|
{"version":3,"file":"multicast.js","sourceRoot":"","sources":["../../src/operator/multicast.ts"],"names":[],"mappings":";AAGA,0BAAyC,wBAAwB,CAAC,CAAA;AAOlE,mCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AACH,mBAAqD,uBAAwD,EAC7E,QAAmD;IACjF,MAAM,CAAC,qBAAW,CAAM,uBAAuB,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAHe,iBAAS,YAGxB,CAAA","sourcesContent":["import { Subject } from '../Subject';\nimport { Observable } from '../Observable';\nimport { ConnectableObservable } from '../observable/ConnectableObservable';\nimport { multicast as higherOrder } from '../operators/multicast';\nimport { FactoryOrValue, MonoTypeOperatorFunction, OperatorFunction } from '../interfaces';\n\n/* tslint:disable:max-line-length */\nexport function multicast<T>(this: Observable<T>, subjectOrSubjectFactory: FactoryOrValue<Subject<T>>): ConnectableObservable<T>;\nexport function multicast<T>(SubjectFactory: (this: Observable<T>) => Subject<T>, selector?: MonoTypeOperatorFunction<T>): Observable<T>;\nexport function multicast<T, R>(SubjectFactory: (this: Observable<T>) => Subject<T>, selector?: OperatorFunction<T, R>): Observable<R>;\n/* tslint:enable:max-line-length */\n\n/**\n * Allows source Observable to be subscribed only once with a Subject of choice,\n * while still sharing its values between multiple subscribers.\n *\n * <span class=\"informal\">Subscribe to Observable once, but send its values to multiple subscribers.</span>\n *\n * <img src=\"./img/multicast.png\" width=\"100%\">\n *\n * `multicast` is an operator that works in two modes.\n *\n * In the first mode you provide a single argument to it, which can be either an initialized Subject or a Subject\n * factory. As a result you will get a special kind of an Observable - a {@link ConnectableObservable}. It can be\n * subscribed multiple times, just as regular Observable, but it won't subscribe to the source Observable at that\n * moment. It will do it only if you call its `connect` method. This means you can essentially control by hand, when\n * source Observable will be actually subscribed. What is more, ConnectableObservable will share this one subscription\n * between all of its subscribers. This means that, for example, `ajax` Observable will only send a request once,\n * even though usually it would send a request per every subscriber. Since it sends a request at the moment of\n * subscription, here request would be sent when the `connect` method of a ConnectableObservable is called.\n *\n * The most common pattern of using ConnectableObservable is calling `connect` when the first consumer subscribes,\n * keeping the subscription alive while several consumers come and go and finally unsubscribing from the source\n * Observable, when the last consumer unsubscribes. To not implement that logic over and over again,\n * ConnectableObservable has a special operator, `refCount`. When called, it returns an Observable, which will count\n * the number of consumers subscribed to it and keep ConnectableObservable connected as long as there is at least\n * one consumer. So if you don't actually need to decide yourself when to connect and disconnect a\n * ConnectableObservable, use `refCount`.\n *\n * The second mode is invoked by calling `multicast` with an additional, second argument - selector function.\n * This function accepts an Observable - which basically mirrors the source Observable - and returns Observable\n * as well, which should be the input stream modified by any operators you want. Note that in this\n * mode you cannot provide initialized Subject as a first argument - it has to be a Subject factory. If\n * you provide selector function, `multicast` returns just a regular Observable, instead of ConnectableObservable.\n * Thus, as usual, each subscription to this stream triggers subscription to the source Observable. However,\n * if inside the selector function you subscribe to the input Observable multiple times, actual source stream\n * will be subscribed only once. So if you have a chain of operators that use
|