import { Component, OnInit, Input, OnDestroy } from '@angular/core'; import { Subscription } from 'rxjs'; import { HBORLoaderService } from '../services/hbor-loader.service'; @Component({ selector: 'hbor-simple-loader', templateUrl: './simple-loader.component.html', styleUrls: ['./simple-loader.component.css'] }) export class SimpleLoaderComponent implements OnInit, OnDestroy { @Input() color = 'primary'; @Input() mode = 'indeterminate'; @Input() isRequesting: boolean; show = false; private subscription: Subscription; constructor( private loaderService: HBORLoaderService ) { } ngOnInit() { this.subscription = this.loaderService.loaderState$ .subscribe((state) => { this.show = state; }); } ngOnDestroy() { this.subscription.unsubscribe(); } }