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

@Injectable({ providedIn: "root" })
export class GlobalService {
  public brands: Subject<any>;
  public features: Subject<any>;

  constructor() {
    this.brands = new Subject();
    this.features = new Subject();
    
    fetch("/api/globals/features").then(r => r.json()).then(
      (results) => {
        this.features.next(results);
        this.features.complete();
      }
    )
    fetch("/api/globals/brands").then(r => r.json()).then(
      (results) => {
        this.brands.next(results);
        this.brands.complete();
      }
    )
  }

}
