Skip to content

Commit

Permalink
fix: clearTimeout on existing toast
Browse files Browse the repository at this point in the history
  • Loading branch information
StephGit committed Feb 20, 2024
1 parent a432be8 commit 4362d7d
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,18 @@ export class ToastComponent {
@Input() message = '';
@Input() type: SuccessOrError;
show = false;
timeoutId = undefined;

public display(message: string, type: SuccessOrError = 'success', duration = 3000) {
this.message = message;
this.type = type;
this.show = true;

setTimeout(() => {
if (this.timeoutId) {
clearTimeout(this.timeoutId);
}

this.timeoutId = setTimeout(() => {
this.show = false;
}, duration);
}
Expand Down

0 comments on commit 4362d7d

Please sign in to comment.