import { Injectable } from '@angular/core';
import { ApiService } from './api.service';

@Injectable({ providedIn: 'root' })
export class PrefetchService {
  private prefetched = new Set<number>();

  constructor(private api: ApiService) {}

  prefetchItem(itemID: number): void {
    if (this.prefetched.has(itemID)) return;
    this.prefetched.add(itemID);
    this.api.getItem(itemID).subscribe();
  }
}
