When I receive a response from the server, I want to redirect to another page. However, this process takes around 60 seconds, so in the meantime, I want to display a spinner. Once the response is received, I should be redirected to the new page. Sounds simple, right?
But here's the issue - the page doesn't automatically redirect when the response is received. Instead, it stays on the same page and only redirects when I click anywhere on the page. It's a bit of a strange situation.
this.optimizationService
.runOptimization(this.runOptimizationModel)
.subscribe(optimizationResult => { // This is the initial service that sends a request to the server.
this.optimizationService.notificationEvent.subscribe(eventData => {
console.log(eventData); // This is another external service for notifications where I want to redirect upon receiving a response.
if (eventData && eventData.length) {
this._router.navigate([this.optimizationResultScreenURL, 'e1517589-905e-485b-b7ee-7bc6521dcc93']); // This line handles the URL redirecting. When placed after the first service subscription, it works correctly.
}
});
});
This unusual behavior may be due to the delay in getting a response from the second service after 60 seconds. It's a peculiar situation, with the 60-second delay acting as the culprit.