RxJS version: 5.5.6
Code to reproduce:
var obs = Rx.Observable.interval(100)
.startWith(0)
.flatMap(() => {
return Rx.Observable.empty();
});
var sub = obs.subscribe(
(data) => {console.log(data, 1)},
(err) => {console.log(err, 2)},
() => {console.log(3)}
);
The above code logs nothing
Expected behavior: next, complete callback should be triggered
Actual behavior: subscribe callbacks not been invoked
Additional information:
if we flatMap returns Rx.Observable.of({}), then callbacks get invoked.
according to RxJS documentation Observable.never() Creates an Observable that emits no items to the Observer.
Observable.empty() Creates an Observable that emits no items to the Observer and immediately emits a complete notification.
var obs = Rx.Observable.empty();
var sub = obs.subscribe(
(data) => {
console.log(data, 1);
},
(err) => {
console.log(err, 2);
},
() => {
console.log(3);
},
);
//the above code logs 3
If we use Observable.interval() then Observable.empty does not emit a complete notification