Observables complete naturally if they are constructed from finite data.
import {Observable, Subject} from "rx";
let stream0$ = Observable.of("1", "2", "3");
let stream1$ = stream0$.map(x => x);
stream1$.subscribe(
(val) => { console.log("onNext", val) },
(err) => { console.log("onError", err) },
() => { console.log("onCompleted") }
);
// onNext 1
// onNext 2
// onNext 3
// onCompleted
Or don't if not. But what about observables subscribed on subjects? For example:
import {Observable, Subject} from "rx";
let subj$ = new Subject();
let stream1$ = subj$.map(x => x);
stream1$.subscribe(
(val) => { console.log("onNext", val) },
(err) => { console.log("onError", err) },
() => { console.log("onCompleted") }
);
subj$.onNext("foo");
// onNext foo
"onCompleted" is not logged though source is ended. Can we pass this "end" event to stream1$
somehow. I've found no information about this important stuff in docs. It would be great to see a diagram like here Hot and Cold observables : are there 'hot' and 'cold' operators? to nail that event flow.