Last active
February 15, 2019 15:45
-
-
Save bampakoa/f041dc4faffcc960ded784360269d186 to your computer and use it in GitHub Desktop.
Wrapper for Angular Material dialog that emits closed event only with return value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private showDialog<T, R>(component: ComponentType<T>, config: MatDialogConfig): Observable<R> { | |
return new Observable(observer => { | |
this.dialog.open<T, any, R>(component, config).afterClosed().subscribe(value => { | |
if (value) { | |
observer.next(value); | |
} | |
observer.complete(); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment