Assume this Angular code:
import { Component } from '@angular/core';
import { shareReplay, tap, timer } from 'rxjs';
@Component({
selector: 'my-app',
template: '{{test$ | async}} {{test$ | async}}',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
test$ = timer(0, 1000).pipe(
shareReplay({ bufferSize: 1, refCount: true }),
tap(console.log)
);
}
Why does console.log
appear twice and the subscription is apparently not shared?
To my knowledge, the overload with config param for shareReplay
is the current recommended way to be explicit about sharing subscriptions. Am I getting something wrong?
rxjs 7.5.2, ng 13.2