1 line
10 KiB
Plaintext
Executable File
1 line
10 KiB
Plaintext
Executable File
{"version":3,"file":"ConnectableObservable.js","sourceRoot":"","sources":["../../src/observable/ConnectableObservable.ts"],"names":[],"mappings":";;;;;;AAAA,wBAA2C,YAAY,CAAC,CAAA;AAExD,2BAA2B,eAAe,CAAC,CAAA;AAC3C,2BAA2B,eAAe,CAAC,CAAA;AAC3C,6BAA4C,iBAAiB,CAAC,CAAA;AAC9D,yBAAgD,uBAAuB,CAAC,CAAA;AAExE;;GAEG;AACH;IAA8C,yCAAa;IAOzD,+BAAY,oCAAoC,CAAQ,MAAqB;QACjE,oCAAoC,CAAQ,cAAgC;QACtF,iBAAO,CAAC;QAF8C,WAAM,GAAN,MAAM,CAAe;QACrB,mBAAc,GAAd,cAAc,CAAkB;QALxF,oCAAoC,CAAQ,cAAS,GAAW,CAAC,CAAC;QAElE,gBAAW,GAAG,KAAK,CAAC;IAKpB,CAAC;IAED,oCAAoC,CAAC,0CAAU,GAAV,UAAW,UAAyB;QACvE,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAED,oCAAoC,CAAQ,0CAAU,GAAjB;QACnC,IAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;YAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACxC,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,uCAAO,GAAP;QACE,IAAI,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;QAClC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;YAChB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;YACzB,UAAU,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,2BAAY,EAAE,CAAC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BAAkB;QAClB,MAAM;QACN,4EAA4E;QAC5E,oEAAoE;QACpE,gDAAgD;QAChD,4EAA4E;QAC5E,6BAA6B;QAC7B,2EAA2E;QAC3E,6CAA6C;QAC7C,GAAG;QACK,gCAAU,CAAU;QAC5B,IAAM,gBAAgB,GAAU,WAAY,CAAC,WAAW,CAAC;QACzD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QAEvB,EAAE,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,UAAU,IAAI,gBAAgB,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC;YACzE,gBAAgB,CAAC,WAAW,EAAE,CAAC;QACjC,CAAC;IACH,CAAC;IACH,yBAAC;AAAD,CAAC,AA7DD,CAAoC,uBAAU,GA6D7C","sourcesContent":["import { Subject, SubjectSubscriber } from '../Subject';\nimport { Operator } from '../Operator';\nimport { Observable } from '../Observable';\nimport { Subscriber } from '../Subscriber';\nimport { Subscription, TeardownLogic } from '../Subscription';\nimport { refCount as higherOrderRefCount } from '../operators/refCount';\n\n/**\n * @class ConnectableObservable<T>\n */\nexport class ConnectableObservable<T> extends Observable<T> {\n\n /** @deprecated internal use only */ public _subject: Subject<T>;\n /** @deprecated internal use only */ public _refCount: number = 0;\n /** @deprecated internal use only */ public _connection: Subscription;\n _isComplete = false;\n\n constructor(/** @deprecated internal use only */ public source: Observable<T>,\n /** @deprecated internal use only */ public subjectFactory: () => Subject<T>) {\n super();\n }\n\n /** @deprecated internal use only */ _subscribe(subscriber: Subscriber<T>) {\n return this.getSubject().subscribe(subscriber);\n }\n\n /** @deprecated internal use only */ public getSubject(): Subject<T> {\n const subject = this._subject;\n if (!subject || subject.isStopped) {\n this._subject = this.subjectFactory();\n }\n return this._subject;\n }\n\n connect(): Subscription {\n let connection = this._connection;\n if (!connection) {\n this._isComplete = false;\n connection = this._connection = new Subscription();\n connection.add(this.source\n .subscribe(new ConnectableSubscriber(this.getSubject(), this)));\n if (connection.closed) {\n this._connection = null;\n connection = Subscription.EMPTY;\n } else {\n this._connection = connection;\n }\n }\n return connection;\n }\n\n refCount(): Observable<T> {\n return higherOrderRefCount()(this) as Observable<T>;\n }\n}\n\nconst connectableProto = <any>ConnectableObservable.prototype;\n\nexport const connectableObservableDescriptor: PropertyDescriptorMap = {\n operator: { value: null },\n _refCount: { value: 0, writable: true },\n _subject: { value: null, writable: true },\n _connection: { value: null, writable: true },\n _subscribe: { value: connectableProto._subscribe },\n _isComplete: { value: connectableProto._isComplete, writable: true },\n getSubject: { value: connectableProto.getSubject },\n connect: { value: connectableProto.connect },\n refCount: { value: connectableProto.refCount }\n};\n\nclass ConnectableSubscriber<T> extends SubjectSubscriber<T> {\n constructor(destination: Subject<T>,\n private connectable: ConnectableObservable<T>) {\n super(destination);\n }\n protected _error(err: any): void {\n this._unsubscribe();\n super._error(err);\n }\n protected _complete(): void {\n this.connectable._isComplete = true;\n this._unsubscribe();\n super._complete();\n }\n /** @deprecated internal use only */ _unsubscribe() {\n const connectable = <any>this.connectable;\n if (connectable) {\n this.connectable = null;\n const connection = connectable._connection;\n connectable._refCount = 0;\n connectable._subject = null;\n connectable._connection = null;\n if (connection) {\n connection.unsubscribe();\n }\n }\n }\n}\n\nclass RefCountOperator<T> implements Operator<T, T> {\n constructor(private connectable: ConnectableObservable<T>) {\n }\n call(subscriber: Subscriber<T>, source: any): TeardownLogic {\n\n const { connectable } = this;\n (<any> connectable)._refCount++;\n\n const refCounter = new RefCountSubscriber(subscriber, connectable);\n const subscription = source.subscribe(refCounter);\n\n if (!refCounter.closed) {\n (<any> refCounter).connection = connectable.connect();\n }\n\n return subscription;\n }\n}\n\nclass RefCountSubscriber<T> extends Subscriber<T> {\n\n private connection: Subscription;\n\n constructor(destination: Subscriber<T>,\n private connectable: ConnectableObservable<T>) {\n super(destination);\n }\n\n /** @deprecated internal use only */ _unsubscribe() {\n\n const { connectable } = this;\n if (!connectable) {\n this.connection = null;\n return;\n }\n\n this.connectable = null;\n const refCount = (<any> connectable)._refCount;\n if (refCount <= 0) {\n this.connection = null;\n return;\n }\n\n (<any> connectable)._refCount = refCount - 1;\n if (refCount > 1) {\n this.connection = null;\n return;\n }\n\n ///\n // Compare the local RefCountSubscriber's connection Subscription to the\n // connection Subscription on the shared ConnectableObservable. In cases\n // where the ConnectableObservable source synchronously emits values, and\n // the RefCountSubscriber's downstream Observers synchronously unsubscribe,\n // execution continues to here before the RefCountOperator has a chance to\n // supply the RefCountSubscriber with the shared connection Subscription.\n // For example:\n // ```\n // Observable.range(0, 10)\n // .publish()\n // .refCount()\n // .take(5)\n // .subscribe();\n // ```\n // In order to account for this case, RefCountSubscriber should only dispose\n // the ConnectableObservable's shared connection Subscription if the\n // connection Subscription exists, *and* either:\n // a. RefCountSubscriber doesn't have a reference to the shared connection\n // Subscription yet, or,\n // b. RefCountSubscriber's connection Subscription reference is identical\n // to the shared connection Subscription\n ///\n const { connection } = this;\n const sharedConnection = (<any> connectable)._connection;\n this.connection = null;\n\n if (sharedConnection && (!connection || sharedConnection === connection)) {\n sharedConnection.unsubscribe();\n }\n }\n}\n"]} |