publishBehavior

function deprecated

Creates a ConnectableObservable that utilizes a BehaviorSubject.

Deprecation Notes

Will be removed in v8. To create a connectable observable that uses a BehaviorSubject under the hood, use connectable. source.pipe(publishBehavior(initValue)) is equivalent to connectable(source, { connector: () => new BehaviorSubject(initValue), resetOnDisconnect: false }). If you're using refCount after publishBehavior, use the share operator instead. source.pipe(publishBehavior(initValue), refCount()) is equivalent to source.pipe(share({ connector: () => new BehaviorSubject(initValue), resetOnError: false, resetOnComplete: false, resetOnRefCountZero: false })). Details: https://rxjs.dev/deprecations/multicasting

publishBehavior<T>(initialValue: T): UnaryFunction<Observable<T>, ConnectableObservable<T>>

Deprecation Notes

Will be removed in v8. To create a connectable observable that uses a BehaviorSubject under the hood, use connectable. source.pipe(publishBehavior(initValue)) is equivalent to connectable(source, { connector: () => new BehaviorSubject(initValue), resetOnDisconnect: false }). If you're using refCount after publishBehavior, use the share operator instead. source.pipe(publishBehavior(initValue), refCount()) is equivalent to source.pipe(share({ connector: () => new BehaviorSubject(initValue), resetOnError: false, resetOnComplete: false, resetOnRefCountZero: false })). Details: https://rxjs.dev/deprecations/multicasting

Parameters

initialValue

The initial value passed to the BehaviorSubject.

Returns

UnaryFunction<Observable<T>, ConnectableObservable<T>>: A function that returns a ConnectableObservable

© 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/operators/publishBehavior