I have a method that needs to wait for an observable to finish. I know observable are great for returning single pieces of data over time but I need to know when this observable has completely finished returning all of its data so I can run validation code on the object it has returned.
The method getCustom subscribes to an observable run on the supplied url which then returns the observable.
I am not too sure if this is the best way to approach this situation so I would appreciate if anyone could give me any advice or a direction to handle this.
private validateQuoteRetrievalAnswers(reference: string) {
// Get the risk from the server
this.riskManager.getRiskFromServer(reference);
if (this.riskManager.risk) {
// Validate risk that was returned
}
}
getRiskFromServer(quoteReference: string) {
this.riskService.getCustom("Url").subscribe => {
// need to know when the observable has returned the risk
});
}