Using Rx.Subject with Angular, it is no different from using it without Angular, the basic principle is the same, see example below
const subject = new Rx.Subject(); const subscription = subject.subscribe( (data) => console.log(data), (err) => console.log(err), () => console.log('Completed') ); subject.next(1); subject.next(2); subject.next(3); subject.complete();
<script src="https://unpkg.com/@reactivex/ rxjs@5.0.0-beta.7 /dist/global/Rx.umd.js"></script>
You need to create a new instance of Rx.Subject , then subscribe to it where you need it and fire the event.
source share