Skip to content

Commit 9179128

Browse files
committed
reworked dialog closeAll & open events based on feedback
1 parent b1289b5 commit 9179128

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

src/demo-app/dialog/dialog-demo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export class DialogDemo {
2727
// Possible useful example for the open and closeAll events.
2828
// Adding a class to the body if a dialog opens and
2929
// removing it after all open dialogs are closed
30-
dialog.afterOpen().subscribe((ref: MdDialogRef<any>) => {
30+
dialog.afterOpen.subscribe((ref: MdDialogRef<any>) => {
3131
if (!doc.body.classList.contains('no-scroll')) {
3232
doc.body.classList.add('no-scroll');
3333
}
3434
});
35-
dialog.afterAllClosed().subscribe(_ => {
35+
dialog.afterAllClosed.subscribe(() => {
3636
doc.body.classList.remove('no-scroll');
3737
});
3838
}

src/lib/dialog/dialog.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ describe('MdDialog', () => {
137137

138138
it('should notify the observers if a dialog has been opened', () => {
139139
let ref: MdDialogRef<PizzaMsg>;
140-
dialog.afterOpen().subscribe(r => {
140+
dialog.afterOpen.subscribe(r => {
141141
ref = r;
142142
});
143143
expect(dialog.open(PizzaMsg, {
@@ -154,7 +154,7 @@ describe('MdDialog', () => {
154154
});
155155
let allClosed = false;
156156

157-
dialog.afterAllClosed().subscribe(_ => {
157+
dialog.afterAllClosed.subscribe(() => {
158158
allClosed = true;
159159
});
160160

src/lib/dialog/dialog.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ export class MdDialog {
2525
private _openDialogs: MdDialogRef<any>[] = [];
2626

2727
/** Subject for notifying the user that all open dialogs have finished closing. */
28-
private _afterAllClosed: Subject<any> = new Subject();
28+
private _afterAllClosed = new Subject<void>();
2929

3030
/** Subject for notifying the user that a dialog has opened. */
31-
private _afterOpen: Subject<any> = new Subject();
31+
private _afterOpen = new Subject<MdDialogRef<any>>();
32+
33+
/** Gets an observable that is notified when a dialog has been opened. */
34+
afterOpen = this._afterOpen.asObservable();
35+
36+
/** Gets an observable that is notified when all open dialog have finished closing. */
37+
afterAllClosed = this._afterAllClosed.asObservable();
3238

3339
constructor(private _overlay: Overlay, private _injector: Injector) { }
3440

@@ -67,20 +73,6 @@ export class MdDialog {
6773
}
6874
}
6975

70-
/**
71-
* Gets an observable that is notified when a dialog has been opened.
72-
*/
73-
afterOpen(): Observable<any> {
74-
return this._afterOpen.asObservable();
75-
}
76-
77-
/**
78-
* Gets an observable that is notified when all open dialog have finished closing.
79-
*/
80-
afterAllClosed(): Observable<any> {
81-
return this._afterAllClosed.asObservable();
82-
}
83-
8476
/**
8577
* Creates the overlay into which the dialog will be loaded.
8678
* @param dialogConfig The dialog configuration.

0 commit comments

Comments
 (0)