Recently, I developed an application where I utilized the behavior subject for data transfer between all components. I am curious to know if this is considered a best practice when working with observables.
import { BehaviorSubject } from 'rxjs';
const subject = new BehaviorSubject(123);
// Two new subscribers will initially receive the value => output: 123, 123
subject.subscribe(console.log);
subject.subscribe(console.log);
// Two subscribers will now receive the new value when it changes => output: 456, 456
subject.next(456);
// A new subscriber will receive the latest value (456) => output: 456
subject.subscribe(console.log);