I need to know how to keep subscription after an error has thrown.
I've created this observable:
let saveClick$ = Observable.fromEvent(this.saveButton.nativeElement, 'click');
So, I've tried with Observable.empty, but as far I've been able to figure out it emits an complete, so subscriber will be removed:
this.saved$ = saveClick$.pipe(this.pushUser(), catchError(() => Observable.empty<AdministrationUser>()), share());
I want that when any error is reached, subscription is kept.
Any ideas?
Additional code:
// Custom pipes
private push = <T>() => switchMap<T, AdministrationUser>(() => this.service.push(this.user));
private handleError = <T>() => catchError<T, Array<{code: string, message: string}>>((error: ResponseError) => Observable.of(error.errors));
private handleEmptyUser = <T>() => catchError<T, AdministrationUser>(() => Observable.of(UsuarisadministracioSubcomponentComponent.EMPTY_USER));
private pushUser = () => pipe( //simplified pipe
this.push()
);
And my service is:
const buildURL = () => map((filter: {userId: string} & Trace) => this.buildPushURL(filter.currentUser, filter.currentApplication, filter.userId));
const makeRequest = () => switchMap((url: string) => httpMethodFn.call(this.authHttp, url, user));
const buildResponse = () => map(() => user);
const onErrorGetDetails = () => catchError((error: Response) => Observable.throw(<ResponseError>error.json()));
return Observable.of({userId: user.id})
.pipe(
buildURL(),
makeRequest(),
buildResponse(),
onErrorGetDetails()
);