Services: add toast

This commit is contained in:
Toast 2025-01-29 10:33:53 +01:00
parent 22cc1dcc01
commit 7ee8e7e3ed
9 changed files with 94 additions and 1 deletions

View file

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ToastService } from './toast.service';
describe('ToastService', () => {
let service: ToastService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ToastService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View file

@ -0,0 +1,17 @@
import { Injectable } from '@angular/core';
import {Toast} from '../../interfaces/toast';
@Injectable({
providedIn: 'root'
})
export class ToastService {
toasts: Toast[] = [];
show(toast: Toast) {
this.toasts.push(toast);
}
remove(toast: Toast) {
this.toasts = this.toasts.filter(t => t != toast);
}
}