This is crucial to understand! Online materials can often be incorrect.
Very short but meaty writeup.
🏆 Here are 4 Laws of Observables 🏆
Law 1
• All Observables are lazy, without exception.
Law 2
• Observables are either cold, serving a single execution context per subscription in a unicast manner.
• Or hot, serving one or more subscribers with the same execution context, in a multicast manner.
Law 3
• Subject is both an Observable and an Observer
• The Observable part is multicast, but still lazily executed only when the first subscriber comes.
• The Observer part is the one created eagerly that allows us to call .next() and send data through the Subject;
• The Observer part does not imply that the execution context of the Observable is 'alive' before the first subscription is made.
Law 4
• There are stateful Subjects, like BehaviorSubject or ReplySubject, which extend the Observer part.
• Adding support for holding 1..n previous states, which the Observable part will multicast to potential subscribers.
By reading this, do you think that RxJS is a complex subject (pun intended :D)?
Angular Team announced plans to potentially make RxJS optional in the future.
Would you like to keep RxJS mandatory?
Or optional is the right way to go?