import { Injectable } from '@angular/core';
import {
  ActivatedRouteSnapshot,
  Resolve,
  Router,
  RouterStateSnapshot,
} from '@angular/router';
import { catchError, Observable, throwError } from 'rxjs';

import { EvoService } from '../services/evo.service';

@Injectable({
  providedIn: 'root',
})
export class EvoResolver implements Resolve<any> {
  /**
   * Constructor
   */
  constructor(private _evoService: EvoService) {}

  // -----------------------------------------------------------------------------------------------------
  // @ Public methods
  // -----------------------------------------------------------------------------------------------------

  /**
   * Resolver
   *
   * @param route
   * @param state
   */
  resolve(
    route: ActivatedRouteSnapshot,
    state: RouterStateSnapshot
  ): Observable<{
    evoSetting: any;
  }> {
    return this._evoService.getEvoSetting();
  }
}
