
- RxJS Tutorial
- RxJS - Home
- RxJS - Overview
- RxJS - Environment Setup
- RxJS - Latest Updates
- RxJS - Observables
- RxJS - Operators
- RxJS - Working with Subscription
- RxJS - Working with Subjects
- RxJS - Working with Scheduler
- RxJS - Working with RxJS & Angular
- RxJS - Working with RxJS & ReactJS
- RxJS Useful Resources
- RxJS - Quick Guide
- RxJS - Useful Resources
- RxJS - Discussion
RxJS - Multicasting Operator publishLast
publishBehaviour make use of AsyncSubject, and returns ConnectableObservable. The connect() method has to be used to subscribe to the observable created.
Example
import { interval } from 'rxjs'; import { take, publishLast} from 'rxjs/operators'; let observer = interval(1000).pipe( take(10), publishLast() ); const subscribe_one = observer.subscribe( x => console.log("Value from Sub1 = "+x) ); const subscribe_two = observer.subscribe( x => console.log("Value from Sub2 = "+x) ); observer.connect();
Output

Advertisements