Skip to content

Instantly share code, notes, and snippets.

@yjaaidi
Last active May 30, 2018 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yjaaidi/f10b7c0ab1d040bcb812f4d1078581a1 to your computer and use it in GitHub Desktop.
Save yjaaidi/f10b7c0ab1d040bcb812f4d1078581a1 to your computer and use it in GitHub Desktop.
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.collect())
.subscribe(count => this.count = count);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment