import { OnInit, AfterViewInit } from '@angular/core';
import { BehaviorSubject, map } from 'rxjs';
constructor(private router: Router) {}
count = new BehaviorSubject(0);
doubled = this.count.pipe(map((value) => value * 2));
ngOnInit(): void {
this.doubled?.subscribe((value: number) => console.log(value));
}
ngAfterViewInit(): void {
this.count.next(1);
this.count.next(2);
}
// OUTPUT VALUES:
// 0
// 2