import { Component, OnInit } from '@angular/core'; | |
import { Scavenger } from '@wishtack/rx-scavenger'; | |
import { interval } from 'rxjs'; | |
@Component({ | |
template: `<div>{{ count }}</div>` | |
}) | |
export class CounterComponent implements OnDestroy, OnInit { | |
count: number; | |
private _scavenger = new Scavenger(this); | |
ngOnInit() { | |
this.startCounting(); | |
} | |
ngOnDestroy() { | |
} | |
startCounting() { | |
interval(1000) | |
.pipe(this._scavenger.collectByKey('count')) | |
.subscribe(count => this.count = count); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment