Skip to content

Instantly share code, notes, and snippets.

@bampakoa
Last active February 15, 2019 15:45
Show Gist options
  • Save bampakoa/f041dc4faffcc960ded784360269d186 to your computer and use it in GitHub Desktop.
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
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