import { Component } from '@angular/core';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';

import { LoaderStore } from '../../interfaces/store/loader.interface';

@Component({
  selector: 'app-loader',
  templateUrl: './loader.component.html',
  styleUrls: ['./loader.component.scss'],
})
export class LoaderComponent {
  loader$: Observable<LoaderStore>;
  isLoading = false;

  constructor(private store: Store<{ loader: LoaderStore }>) {
    this.loader$ = this.store.select('loader');
  }

  ngOnInit() {
    this.loader$.subscribe({
      next: (data) => (this.isLoading = data.isLoading),
    });
  }
}
