rxjs

RXJS Repeat query until a condition is met?

筅森魡賤 提交于 2020-08-27 08:55:12
问题 I'm using an API that returns only a limited number of results, say 100. I'd like to repeat a query until the return result set is < 100 which would mean I've got the last result. So it would go like this: Make query Is result set less than limit? If so, do again and append results. Once result set is less than limit, emit the final result. 回答1: You can use the expand operator for a simple "conditional repeat" behavior. Just for the example, instead of a result set I changed the query to

rxjs observable reusing logic

折月煮酒 提交于 2020-08-24 09:51:58
问题 I'm writing a angular file-upload component. Upon successful upload, it displays a notice and two buttons: replace : deletes uploaded file and opens the file-selector dialog remove : deletes uploaded file and displays a notice Deleting the uploaded file means making a HTTP DELETE request to a backend system and handling possible failure and retries. _handleReplace() { this.replaceClicked$.pipe( tap((x) => this._backend.delete(this.file, this.fieldName)), tap((x) => openFileSelectorDialog()) )