I'm building an Angular 6 application with a progress bar that displays the rendering and downloading progress of a PDF file as a percentage. Here's my Post call:
renderReport(renderObjectId: number): Observable<HttpEvent<Blob>> {
return this.httpService.post('/render/report/' + renderObjectId, {
observe: 'events',
responseType: 'blob'
});
}
The corresponding backend method looks like this:
[HttpPost]
[Route("report/{renderReportId}")]
[ResponseType(typeof(HttpResponseMessage))]
public HttpResponseMessage PrintReport(int renderReportId)
{
var man = new RenderingManager();
MemoryStream pdfFileStream = man.RenderReport(renderReportId);
return CreatePdfDownload(pdfFileStream);
}
The RenderReport()
method takes some time because it involves writing and validating XML.
I want to be able to subscribe to updates from the backend in the frontend, such as "currently in step 5 of 12 in RenderReport()". Is there a way to achieve this, possibly by manually returning status updates after each method call within RenderReport
?