BACK
ReferencepublishBehavior
Reference · 86

publishBehavior

publishBehavior

Deprecated
rxjs.dev

Multicast via a BehaviorSubject.

Signature

publishBehavior(initialValue: T): UnaryFunction, ConnectableObservable>

What it does

Creates a connectable Observable over a BehaviorSubject with initialValue, so a subscriber can see the starting value.

When to use

Supporting legacy code. For new state, a BehaviorSubject directly, or share with a connector, is usually better.

Deprecated API

Marked deprecated in RxJS 7. In new code, use share({ connector: () => new BehaviorSubject(value) }).

See also

share, BehaviorSubject

script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...