import { Injectable } from '@angular/core';
import { Subject, Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class MyServiceService {
  public constructor() { }

  private subject = new Subject<any>();
  sendMsg(data) {
    let that = this;
    setTimeout(() => {
      that.subject.next(data);
    }, 1);
  }
  getMsg(): Observable<any> {
    return this.subject.asObservable();
  }
}
