Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 79x 79x 79x 79x 2x 2x 2x 2x | import { Component, Input } from '@angular/core';
import { catchError, Observable, of } from 'rxjs';
import { LoadingComponent } from '../../loading/loading.component';
import { ActionComponent } from '../action.component';
@Component({
selector: 'app-inline-button',
templateUrl: './inline-button.component.html',
styleUrls: ['./inline-button.component.scss'],
host: { 'class': 'action' },
imports: [LoadingComponent]
})
export class InlineButtonComponent extends ActionComponent {
@Input()
action: () => Observable<any|never> = () => of(null);
@Input()
minDelayMs = 1000;
acting = false;
minTimeout = false;
override reset() {
this.acting = false;
}
override active() {
return this.acting;
}
act() {
this.acting = true;
this.minTimeout = true;
setTimeout(() => this.minTimeout = false, this.minDelayMs);
this.action().pipe(
catchError(() => of(null)),
).subscribe(() => this.acting = false);
}
}
|