initiative.component.ts 741 B

123456789101112131415161718192021222324252627282930
  1. import { Component } from '@angular/core';
  2. import { DataService } from 'src/services/data/data.service';
  3. @Component({
  4. selector: 'initiative',
  5. templateUrl: './initiative.component.html',
  6. styleUrls: ['./initiative.component.scss'],
  7. })
  8. export class InitiativeComponent {
  9. public constructor(public dataAccessor: DataService) {}
  10. public initiative: number = 0;
  11. ngOnInit(): void {
  12. this.initAttributeSubscription();
  13. }
  14. private initAttributeSubscription(): void {
  15. this.dataAccessor.initiative$.subscribe((newValue: any) => {
  16. this.initiative = newValue.value;
  17. });
  18. }
  19. public updateValue(): void {
  20. this.dataAccessor.updateCharacterData({
  21. name: 'initiative',
  22. value: this.initiative,
  23. });
  24. }
  25. }