Services: add toast
This commit is contained in:
parent
22cc1dcc01
commit
7ee8e7e3ed
9 changed files with 94 additions and 1 deletions
16
src/services/toast/toast.service.spec.ts
Normal file
16
src/services/toast/toast.service.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
17
src/services/toast/toast.service.ts
Normal file
17
src/services/toast/toast.service.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue