import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { MatchedResult, RegexReplacement} from './matched-result.model'


@Injectable({
  providedIn: 'root'
})

export class MatchService {
  private matchesSubject = new BehaviorSubject<MatchedResult[]>([]);
  matches$ = this.matchesSubject.asObservable();

  private regexReplacementSubject = new BehaviorSubject<RegexReplacement | null>(null);
  regexReplacement$ = this.regexReplacementSubject.asObservable();

  setMatches(matches: MatchedResult[]) {
    this.matchesSubject.next(matches);
  }

  setRegextReplacement(regexReplacement: RegexReplacement) {
    this.regexReplacementSubject.next(regexReplacement);
  }
  
}
