RxJS/Documentation/observable : Différence entre versions
Version actuelle en date du 20 juillet 2019 à 19:02
In ReactiveX an observer subscribes to an Observable.
Then that observer reacts to whatever item or sequence of items the Observable emits.
This pattern facilitates concurrent operations because it does not need to block while waiting for the Observable to emit objects, but instead it creates a sentry in the form of an observer that stands ready to react appropriately at whatever future time the Observable does so.
Most operators operate on an Observable and return an Observable.
This allows you to apply these operators one after the other, in a chain. Each operator in the chain modifies the Observable that results from the operation of the previous operator.
A Subject is a sort of bridge or proxy that is available in some implementations of ReactiveX that acts both as an observer and as an Observable.
Because it is an observer, it can subscribe to one or more Observables, and because it is an Observable, it can pass through the items it observes by reemitting them, and it can also emit new items.
When an observer subscribes to a BehaviorSubject,
- it begins by emitting the item most recently emitted by the source Observable (or a seed/default value if none has yet been emitted)
- and then continues to emit any other items emitted later by the source Observable(s).
Represents a value that changes over time.
Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications.
This class inherits both from the Rx.Observable and Rx.Observer classes.