I have a confirm/cancel modal dialog that pops up when a user leaves a route. I do this by using a guard with the canDeactivate method. However I want canDeactivate to wait
Use take(1) or first() (don't forget to import)
take(1)
first()
return this.formService.getModalSelectionObservable().first();
to ensure the observable is closed after the first event, otherwise the router will wait until it is closed from the service.