It's hard for me to smash one part of RxJs: when you subscribe to Observable, you only subscribe to any future events from this stream. Compare with Promises, where if the promise is resolved, you will get this value no matter when you call then() .
Here is a sample code:
var subject = new Rx.Subject(); subject.onNext('old value'); subject.onNext('before subscription'); subject.subscribe(function(val) { document.write(val); }); subject.onNext('after subscription');
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/2.3.24/rx.all.js"></script>
I would expect to see both "before subscription" and "after subscription", although it makes sense to me that the "old value" will be reset. But it seems that RxJs does not work like this (it is printed only "after subscription"). How can I get the result that I need?
javascript rxjs
DallonF Feb 03 '15 at 23:59 2015-02-03 23:59
source share