
TypeScript 4 Design Patterns and Best Practices
By :

An observable represents a sequence that is invokable and produces future values or events. The idea is that you create an observable
object and you add observers
to it for receiving future values. Once the observable
pushes a value, observers
will receive them at some point.
Observables build upon the foundational ideas of the observer pattern that we discussed in Chapter 5, Behavioral Design Patterns. However, this pattern worked specifically with classes and its scope was limited. Observables, on the other hand, try to expand the idea of composing asynchronous and event-based programs that react based on changes.
Within the scope of Reactive programming, observables represent the producers of future values, and observers represent the consumers. By default, the communication happens as soon as the observable has any observers, so it waits to be invoked (subscribed) before it can emit any data. The association between the producer and the consumer is decoupled...