From 72fee038a5b331db986aac6758b22faf0339d283 Mon Sep 17 00:00:00 2001 From: TheDiaval Date: Thu, 9 Jan 2020 21:01:31 +0300 Subject: [PATCH] feat(theme-shared): add clear toasts by key functionality related issue: #2537 --- .../theme-shared/src/lib/services/toaster.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/services/toaster.service.ts b/npm/ng-packs/packages/theme-shared/src/lib/services/toaster.service.ts index e7cd005990..818b44bf97 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/services/toaster.service.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/services/toaster.service.ts @@ -71,7 +71,7 @@ export class ToasterService { message, title, severity, - options: { closable: true, ...options, id }, + options: { closable: true, id, ...options }, }); this.toasts$.next(this.toasts); return id; @@ -89,8 +89,8 @@ export class ToasterService { /** * Removes all open toasts at once. */ - removeAll() { - this.toasts = []; + clear(key?: string) { + this.toasts = !key ? [] : this.toasts.filter(toast => toast.options.containerKey !== key); this.toasts$.next(this.toasts); } }