what is diference between observable created from of or from and those created from subjects, or behaviour subjects?
This is a general question regarding what's the difference:
of([1, 2, 3]).subscribe(x => console.log(x));
from([1, 2, 3]).subscribe(x => console.log(x));
vs
const subject = new BehaviorSubject();
// subscriber 1
subject.subscribe((data) => {
console.log('Subscriber A:', data);
});
subject.next(Math.random());
subject.next(Math.random());
The one thing I know is that with subjects we have control over the values emitted where as with observables we dont.
But consider this, ain't piping observables the same as controlling the observables. So what makes the difference?
I have gone through different posts on SO regarding this topic, but nothing is convincing enough!
What is the difference between a Observable and a Subject in rxjs?
It is said that subjects are used for multi casting, ie for delivering same values to all subscribers. So aint' observables also doin the same or are they delivering them differently.