redoc/lib/services/warnings.service.ts

21 lines
526 B
TypeScript
Raw Normal View History

'use strict';
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable()
export class WarningsService {
2017-07-22 18:04:54 +03:00
public static warnings = new BehaviorSubject<Array<string>>([]);
2017-07-22 18:04:54 +03:00
private static _warnings: Array<string> = [];
static hasWarnings() {
return !!WarningsService._warnings.length;
}
static warn(message:string) {
WarningsService._warnings.push(message);
2017-07-22 18:04:54 +03:00
WarningsService.warnings.next(WarningsService._warnings);
console.warn(message);
}
}