File

src/app/core/notify.service.ts

Index

Properties
Methods

Methods

clear
clear()
Returns : void
update
update(content: string, style: "error" | "info" | "success")
Parameters :
Name Type Optional
content string No
style "error" | "info" | "success" No
Returns : void

Properties

Private _msgSource
Default value : new Subject<Msg | null>()
msg
Default value : this._msgSource.asObservable()
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';

export interface Msg {
  content: string;
  style: string;
}

@Injectable()
export class NotifyService {
  private _msgSource = new Subject<Msg | null>();
  msg = this._msgSource.asObservable();

  update(content: string, style: 'error' | 'info' | 'success') {
    console.log(content);
    const msg: Msg = { content, style };
    this._msgSource.next(msg);
  }

  clear() {
    this._msgSource.next(null);
  }
}

result-matching ""

    No results matching ""