( Stackblitz )
// RxJS v6+
import { AsyncSubject } from 'rxjs';
const sub = new AsyncSubject();
sub.subscribe(console.log);
sub.next(123); //nothing logged
sub.subscribe(console.log);
sub.next(456); //nothing logged
sub.complete(); //456, 456 logged by both subscribers
- AsyncSubject 📰 - Official docs
- AsyncSubject - In Depth Dev Reference
📁 Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/internal/AsyncSubject.ts