import { Component, ElementRef, HostListener } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
import { ImagesService } from '../../services/images.service';
import { ProductInterface } from '../../pages/linea/linea.component';
import { debounce, debounceTime, distinctUntilChanged, switchMap } from 'rxjs';

interface Pais {
  IDPAIS: string;
  NOMBRE: string;
  LADA: number;
}

@Component({
    selector: 'app-prueba',
    templateUrl: './prueba.component.html',
    styleUrls: ['./prueba.component.css'],
    standalone: false
})
export class PruebaComponent {
  productos: ProductInterface[] = [];
  searchControl = new FormControl('');

  constructor(private _imageService: ImagesService) {
    this.searchControl.valueChanges.pipe(
      debounceTime(300),
      distinctUntilChanged(),
      switchMap(value => this._imageService.finder(value || ''))
    ).subscribe((response: any) => {
      this.productos = response;
    })

  }




}
