I am trying to understand rxjs (6) and how I should call conditionally make a second http post.
My scenario is that:
- I am/have uploaded a file.
- I get an object identifying the current progress and a filename.
- If the current progress is 100 I want to make the second http post and on success of that second call return the progress and the filename
- If the current progress is less than 100 simply return the progress and filename
My class
export class BasePortalDetailsManagerService {
updateCertificate(file: File): Observable<IUploadProgress> {
return this._azureBlobStorage
.uploadCertificateToBlobStorage2(file, this.portalKey)
.pipe(
map(progress => this.mapProgress2(progress))
);
}
private mapProgress2(fileProgress: FileProgress): IUploadProgress {
if (fileProgress.Progress === 100) {
console.log('I can do something here but there must be a better way');
} else {
return {
filename: fileProgress.FilePath,
progress: fileProgress.Progress
};
}
}
}
I have been watching and reading various stuff and the only that seems to happen is, it convinces me my way is wrong. I cant seem to get my head round the various tutorials.
various links I've followed