@@ -15,7 +15,7 @@ import {RxChain, first, filter} from '../core/rxjs/index';
15
15
16
16
17
17
// TODO(jelbourn): resizing
18
- // TODO(jelbourn): afterOpen and beforeClose
18
+ // TODO(jelbourn): afterOpen
19
19
20
20
// Counter for unique dialog ids.
21
21
let uniqueId = 0 ;
@@ -33,6 +33,9 @@ export class MdDialogRef<T> {
33
33
/** Subject for notifying the user that the dialog has finished closing. */
34
34
private _afterClosed : Subject < any > = new Subject ( ) ;
35
35
36
+ /** Subject for notifying the user that the dialog has started closing. */
37
+ private _beforeClose : Subject < any > = new Subject ( ) ;
38
+
36
39
/** Result to be passed to afterClosed. */
37
40
private _result : any ;
38
41
@@ -63,7 +66,11 @@ export class MdDialogRef<T> {
63
66
RxChain . from ( this . _containerInstance . _animationStateChanged )
64
67
. call ( filter , event => event . phaseName === 'start' )
65
68
. call ( first )
66
- . subscribe ( ( ) => this . _overlayRef . detachBackdrop ( ) ) ;
69
+ . subscribe ( ( ) => {
70
+ this . _beforeClose . next ( dialogResult ) ;
71
+ this . _beforeClose . complete ( ) ;
72
+ this . _overlayRef . detachBackdrop ( ) ;
73
+ } ) ;
67
74
68
75
this . _containerInstance . _startExitAnimation ( ) ;
69
76
}
@@ -75,6 +82,13 @@ export class MdDialogRef<T> {
75
82
return this . _afterClosed . asObservable ( ) ;
76
83
}
77
84
85
+ /**
86
+ * Gets an observable that is notified when the dialog has started closing.
87
+ */
88
+ beforeClose ( ) : Observable < any > {
89
+ return this . _beforeClose . asObservable ( ) ;
90
+ }
91
+
78
92
/**
79
93
* Updates the dialog's position.
80
94
* @param position New dialog position.
0 commit comments