ConnectableObservable

class deprecated

Deprecation Notes

Will be removed in v8. Use connectable to create a connectable observable. If you are using the refCount method of ConnectableObservable, use the share operator instead. Details: https://rxjs.dev/deprecations/multicasting

class ConnectableObservable<T> extends Observable {
  constructor(source: Observable<T>, subjectFactory: () => Subject<T>)
  protected _subject: Subject<T> | null
  protected _refCount: number
  protected _connection: Subscription | null
  source: Observable<T>
  protected subjectFactory: () => Subject<T>
  protected getSubject(): Subject<T>
  protected _teardown()
  connect(): Subscription
  refCount(): Observable<T>

  // inherited from index/Observable
  static create: (...args: any[]) => any
  constructor(subscribe?: (this: Observable<T>, subscriber: Subscriber<T>) => TeardownLogic)
  source: Observable<any> | undefined
  operator: Operator<any, T> | undefined
  lift<R>(operator?: Operator<T, R>): Observable<R>
  subscribe(observerOrNext?: Partial<Observer<T>> | ((value: T) => void), error?: (error: any) => void, complete?: () => void): Subscription
  forEach(next: (value: T) => void, promiseCtor?: PromiseConstructorLike): Promise<void>
  pipe(...operations: OperatorFunction<any, any>[]): Observable<any>
  toPromise(promiseCtor?: PromiseConstructorLike): Promise<T | undefined>
}

Constructor

constructor(source: Observable<T>, subjectFactory: () => Subject<T>)

Deprecation Notes

Will be removed in v8. Use connectable to create a connectable observable. new ConnectableObservable(source, factory) is equivalent to connectable(source, { connector: factory }). When the refCount() method is needed, the share operator should be used instead: new ConnectableObservable(source, factory).refCount() is equivalent to source.pipe(share({ connector: factory })). Details: https://rxjs.dev/deprecations/multicasting

Parameters

source

The source observable

subjectFactory

The factory that creates the subject used internally.

Properties

Property Type Description
_subject Subject<T> | null
_refCount number
_connection Subscription | null
source Observable<T>

The source observable

Declared in constructor.
subjectFactory () => Subject<T>

The factory that creates the subject used internally.

Declared in constructor.

Methods

protected getSubject(): Subject<T>

Parameters

There are no parameters.

Returns

Subject<T>

protected _teardown()

Parameters

There are no parameters.

connect(): Subscription

Deprecation Notes

ConnectableObservable

will be removed in v8. Use connectable instead. Details: https://rxjs.dev/deprecations/multicasting

Parameters

There are no parameters.

Returns

Subscription

refCount(): Observable<T>

Deprecation Notes

ConnectableObservable

will be removed in v8. Use the share operator instead. Details: https://rxjs.dev/deprecations/multicasting

Parameters

There are no parameters.

Returns

Observable<T>

© 2015–2021 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/index/class/ConnectableObservable