#How to prevent unsubscribe on observable error
14 messages · Page 1 of 1 (latest)
OTOH, once a subject (or any other observable) has errored, it won't ever emit again, which is why you're automatically unsubscribed. I guess it's not the subject which signals an error, but some other observable down the pipeline. You probably need to catch those errors. But without code, all we can do is guess.
Ok im back lmao
async loadGridOpenSearch(openSearch: any): Promise<Document[]> {
if (openSearch === '' && openSearch.length > 3)
return [];
const response = this.prodoctivityService
.getDocumentsByKeywordValue(openSearch, false)
const dataPromise = lastValueFrom(response);
dataPromise.catch((error) => {
console.error(error);
return Promise.resolve([]);
});
const data = await dataPromise;
return data.map<Document>((document) => ({
filename: document.documentName,
createdBy: '',
documentType: document.documentType,
documentCategory: document.categoryName,
documentId: document.documentHandle,
modifiedDate: new Date().toDateString(),
}))
}
@night dock
Tried it, but isnt retry so risky? Damn
There is no subscription, no Subject, no observable in the code you posted. So I have really no idea of what you're asking.
Ojlh sorry i accidentally got banned
this.data$ = this.dataSubject$.pipe(
debounceTime(500),
distinctUntilChanged(),
switchMap((result: any) => {
return concat(of({loading: true}), this.retrieveData(result));
}
),
retry(),
share()
)
So, let's say a new data is emitted by the subject, which causes retriveData to be called, and finally the new data, I guess, being displayed. Now another event is emitted from dataSubject, and retrieveData is called again, but fails with an error. What do you want to happen?
i want it to not unsubscribe on error
That's not what I'm asking. Forget about the fact that you're a developer using RxJS. As a user of the application, what would you like to happen when retrieving the data fails?