Why `BehaviorSubject` doesn't emit the last value

Viewed 1866

The documentation on BehaviorSubject states that it should return the last emitted value regardless of when I subscribe but it doesn't return it for me:

const ofObservable = Rx.Observable.of(1, 2, 3);
const subject = new Rx.BehaviorSubject();
ofObservable.subscribe(subject);

subject.subscribe((v) => {
    console.log(v);
}, null, () => {
    console.log('completed');
});

The code logs completed only.

The ReplaySubject works as expected with the above code and log 1, 2, 3, completed.

1 Answers
Related