import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { FleioId } from '@fleio-api/base-model/base-fleio-object.model';

@Injectable({
  providedIn: 'root'
})
export class JournalEditTrackerService {
  private journalChangedBS: BehaviorSubject<FleioId> = new BehaviorSubject<FleioId>(null);
  public readonly journalChanged$: Observable<FleioId> = this.journalChangedBS.asObservable();

  constructor() { }

  notifyJournalChange(id?: FleioId) {
    if (id) {
      this.journalChangedBS.next(id);
    } else {
      this.journalChangedBS.next('unknown-id');
    }
  }
}
