mirror of
https://github.com/mempool/mempool.git
synced 2025-01-10 07:26:46 +01:00
30 lines
640 B
TypeScript
30 lines
640 B
TypeScript
|
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy, Input, ChangeDetectorRef } from '@angular/core';
|
||
|
|
||
|
@Component({
|
||
|
selector: 'app-time-since',
|
||
|
template: `{{ time | timeSince : trigger }}`,
|
||
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||
|
})
|
||
|
export class TimeSinceComponent implements OnInit, OnDestroy {
|
||
|
interval: number;
|
||
|
trigger = 0;
|
||
|
|
||
|
@Input() time: number;
|
||
|
|
||
|
constructor(
|
||
|
private ref: ChangeDetectorRef
|
||
|
) { }
|
||
|
|
||
|
ngOnInit() {
|
||
|
this.interval = window.setInterval(() => {
|
||
|
this.trigger++;
|
||
|
this.ref.markForCheck();
|
||
|
}, 1000 * 60);
|
||
|
}
|
||
|
|
||
|
ngOnDestroy() {
|
||
|
clearInterval(this.interval);
|
||
|
}
|
||
|
|
||
|
}
|