import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { Eventoi } from '../interfaces/eventoi';
import { ApiService } from './api.service';

@Injectable({
  providedIn: 'root'
})
export class FeedService {

  eventos: Eventoi[];
  eventoIndex: number;

  constructor(private apiService: ApiService, private router: Router) { }

  initFeed(): void{
    this.apiService.getEventos()
    .subscribe(eventos => {
      this.eventos = eventos;
      this.router.navigate(['/tabsUser'])
    })
  }

  getEventoByIndex(eventoIndex: number):Eventoi{
    return this.eventos[eventoIndex];
  } 

  
}
