I'm trying to understand how the stream is transmitted through the pipe in RXjs.
I know that this should not be a concern because that's the whole idea with async streams - but still there's something I want to understand.
Looking at this code :
var source = Rx.Observable
.range(1, 3)
.flatMapLatest(function (x) { //`switch` these days...
return Rx.Observable.range(x*100, 2);
});
source.subscribe(value => console.log('I got a value ', value))
Result :
I got a value 100
I got a value 200
I got a value 300
I got a value 301
I believe (IIUC) that the diagram is something like this : (notice striked 101,201 which are unsubscribed)
----1---------2------------------3------------------------------|
░░░░░░░░flatMapLatest(x=>Rx.Observable.range(x*100, 2))░░░░░░░░
-----100-------(-̶1̶0̶1̶)-------200---(-̶2̶0̶1̶)-----300------301-------------
And here is the question:
Question:
Is it always guaranteed that 2 will arrive before the (101) ? same as that 3 is arriving before (201) ?
I mean - if I'm not suppose to look at a time line so it is perfectly legal for the following diagram to occur :
----1---------------2---------------3------------------------------|
░░░░░░░░flatMapLatest(x=>Rx.Observable.range(x*100, 2))░░░░░░░░
-----100-------101------200---201-----300------301-------------
Where 2
arrived with a slight delay where 101 was already emitted
What am I missing here? How does the pipe work here ?