With a normal Subject, it matters when we start subscribing. If we start emitting values before our subscription is set up, those values are simply lost. If we have a BehaviorSubject, we have a somewhat better scenario. Even if we are late in subscribing, so a value has already been emitted, the very last emitted value is still possible to gain access to. Then the following question arises: What if two or more values are emitted before a subscription happens and we care about those values – what then?
Let's illustrate this scenario and see what happens with a Subject and BehaviorSubject, respectively:
// example of emitting values before subscriptionconst Rx = require("rxjs/Rx");let subject = new Rx.Subject();subject.next(