Reversible blockchain components

This commit is contained in:
Mononaut
2022-09-29 22:45:40 +00:00
parent 135fbfc4f3
commit d07bf30737
9 changed files with 130 additions and 25 deletions

View File

@@ -1,4 +1,5 @@
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
import { Subscription } from 'rxjs';
import { StateService } from '../../services/state.service';
@Component({
@@ -7,8 +8,11 @@ import { StateService } from '../../services/state.service';
styleUrls: ['./blockchain.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BlockchainComponent implements OnInit {
export class BlockchainComponent implements OnInit, OnDestroy {
network: string;
timeLtrSubscription: Subscription;
timeLtr: boolean = this.stateService.timeLtr.value;
ltrTransitionEnabled = false;
constructor(
public stateService: StateService,
@@ -16,5 +20,17 @@ export class BlockchainComponent implements OnInit {
ngOnInit() {
this.network = this.stateService.network;
this.timeLtrSubscription = this.stateService.timeLtr.subscribe((ltr) => {
this.timeLtr = !!ltr;
});
}
ngOnDestroy() {
this.timeLtrSubscription.unsubscribe();
}
toggleTimeDirection() {
this.ltrTransitionEnabled = true;
this.stateService.timeLtr.next(!this.timeLtr);
}
}