Skip to content

Commit 576662e

Browse files
committed
fix(snackbar): make closeWithAction public method
1 parent da1d1ca commit 576662e

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/lib/snack-bar/simple-snack-bar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<button
44
class="mat-simple-snackbar-action"
55
*ngIf="hasAction"
6-
(click)="dismiss()">{{data.action}}</button>
6+
(click)="action()">{{data.action}}</button>

src/lib/snack-bar/simple-snack-bar.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export class SimpleSnackBar {
3636
this.data = data;
3737
}
3838

39-
/** Dismisses the snack bar. */
40-
dismiss(): void {
41-
this.snackBarRef._action();
39+
/** Performs the action on the snack bar. */
40+
action(): void {
41+
this.snackBarRef.closeWithAction();
4242
}
4343

4444
/** If the action button should be shown. */

src/lib/snack-bar/snack-bar-ref.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ export class MdSnackBarRef<T> {
2525
containerInstance: MdSnackBarContainer;
2626

2727
/** Subject for notifying the user that the snack bar has closed. */
28-
private _afterClosed: Subject<any> = new Subject();
28+
private _afterClosed = new Subject<void>();
2929

3030
/** Subject for notifying the user that the snack bar has opened and appeared. */
31-
private _afterOpened: Subject<any>;
31+
private _afterOpened = new Subject<void>();
3232

3333
/** Subject for notifying the user that the snack bar action was called. */
34-
private _onAction: Subject<any> = new Subject();
34+
private _onAction = new Subject<void>();
3535

3636
/**
3737
* Timeout ID for the duration setTimeout call. Used to clear the timeout if the snackbar is
@@ -55,19 +55,19 @@ export class MdSnackBarRef<T> {
5555
clearTimeout(this._durationTimeoutId);
5656
}
5757

58-
/** Dismisses the snack bar after some duration */
59-
_dismissAfter(duration: number): void {
60-
this._durationTimeoutId = setTimeout(() => this.dismiss(), duration);
61-
}
62-
6358
/** Marks the snackbar action clicked. */
64-
_action(): void {
59+
closeWithAction(): void {
6560
if (!this._onAction.closed) {
6661
this._onAction.next();
6762
this._onAction.complete();
6863
}
6964
}
7065

66+
/** Dismisses the snack bar after some duration */
67+
_dismissAfter(duration: number): void {
68+
this._durationTimeoutId = setTimeout(() => this.dismiss(), duration);
69+
}
70+
7171
/** Marks the snackbar as opened */
7272
_open(): void {
7373
if (!this._afterOpened.closed) {

0 commit comments

Comments
 (0)