import {AfterViewInit, Component, Input, ViewRef} from '@angular/core';

import {HsDialogComponent} from 'hslayers-ng';
import {HsDialogContainerService} from 'hslayers-ng';

import {AdjusterEventService} from './adjuster-event.service';
import {AdjusterService} from './adjuster.service';

@Component({
  selector: 'pra-adjuster-loader',
  templateUrl: './adjuster-loader.component.html',
  styleUrls: ['./adjuster-loader.component.scss'],
})
export class AdjusterLoaderComponent
  implements HsDialogComponent, AfterViewInit {
  @Input() data;
  viewRef: ViewRef;
  constructor(
    public hsDialogContainerService: HsDialogContainerService,
    public adjusterService: AdjusterService,
    public adjusterEventService: AdjusterEventService
  ) {
    /*this.adjusterEventService.loaded.subscribe(() => {
      this.hsDialogContainerService.destroy(this);
    });*/
  }

  ngAfterViewInit(): void {
    // The next is necessary, otherwise the forkJoin() would hang up immediately
    this.adjusterEventService.loaderReady.next();
    this.adjusterEventService.loaderReady.complete();
  }
}
