What is the benefit of using "Subscribe providing subject" and what does this entail: 1- The purpose of using subscribe providing subject
import { Subject, from } from 'rxjs';
const newSubject = new Subject<number>();
newSubject.subscribe({
next: (value) => console.log(`observerA: ${value}`)
});
newSubject.subscribe({
next: (value) => console.log(`observerB: ${value}`)
});
const newObservable = from([1, 2, 3]);
newObservable.subscribe(newSubject); // You can subscribe by providing a Subject
// Output:
// observerA: 1
// observerB: 1
// observerA: 2
// observerB: 2
// observerA: 3
// observerB: 3