-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
TypeScript 5 Design Patterns and Best Practices - Second Edition
By :
An Observable represents a sequence that can be invoked and produces Future values or events. The idea is to create an Observable object to receive Future values. Once the observable pushes a value, the observers will receive it at some point.
Observables build upon the fundamental concepts of the Observer pattern discussed in Chapter 5. However, the Observer pattern was specific to classes and had a limited scope. Observables aim to expand the idea of composing asynchronous and event-based programs that react to changes.
In the context of reactive programming, Observables represent the producers of Future values, while observers represent the consumers. By default, communication occurs as soon as the observable has any observers. It waits to be invoked (subscribed) before it can emit any data. The association between the producer and the consumer is decoupled, as they do not need to know the details of how the values are produced or consumed.
Figure...