import { Injectable } from '@angular/core';
import { BaseButtonService } from './base-button.service';

@Injectable({
  providedIn: 'root'
})
export class TransferService extends BaseButtonService {

  private actions: Array<() => void> = [];

  public get count(): number {
    return this.actions.length;
  }

  public get any(): boolean {
    return this.count > 0;
  }

  add(action: () => void): void {
    this.actions.push(action);
  }

  removeAll(): void {
    this.actions = [];
  }

  executeAll(): void {
    this.actions.forEach(action => action());
  }
}