25 lines
429 B
TypeScript
25 lines
429 B
TypeScript
import {Injectable} from '@angular/core';
|
|||
|
|
import {Observable,Subject} from 'rxjs';
|
||
|
|
import {ToastConfig} from './toast-model';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* toast服务
|
||
|
|
*/
|
||
|
|
@Injectable()
|
||
|
|
export class ToastService {
|
||
|
|
|
||
|
|
private toastSubject = new Subject<ToastConfig>();
|
||
|
|
|
||
|
|
constructor() {}
|
||
|
|
|
||
|
|
getToasts(): Observable<ToastConfig> {
|
||
|
|
return this.toastSubject;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
toast(toastConfig: ToastConfig) {
|
||
|
|
this.toastSubject.next(toastConfig);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|