Assume I have function which makes http call and returns Observable with user details.
If user doesn't exist it returns Observable which emits error.
// Get user by id
function getUser(id) {
return Rx.Observable.create(obs => {
if (id === 1) {
obs.next('200 - User found');
obs.complete();
} else {
obs.error('404 - User not found');
}
});
}
// This will print "200 - User found" in the console after 2 seconds
getUser(1)
.delay(2000)
.subscribe(r => console.log(r));
// !!! Delay will not work here because error emmited
getUser(2)
.delay(2000)
.subscribe(null, e => console.log(e));
Is there any way to delay Observable which emits error?