import { Store } from '@ngrx/store';
import { Injectable } from '@angular/core';

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

@Injectable({
  providedIn: 'root',
})
export class LoaderDispatchers {
  constructor(private store: Store<{ loader: LoaderStore }>) {}

  setLoader(newState: LoaderStore) {
    this.store.dispatch(loaderActions.set_loader(newState));
  }

  showLoader() {
    this.store.dispatch(loaderActions.show_loader());
  }

  hideLoader() {
    this.store.dispatch(loaderActions.hide_loader());
  }
}
