I'm curious, why do you think they used the name "Behavior" for the BehaviorSuject object in Ractive Extensions?
note: a behavior subject returns the last value (or the init vaue) as the first value to any subscriber.
Behavior subject is the most common subject in angular. The Behavior subject represents the current value and it is imported from the Rxjs library. It is similar to the subject but the difference is that we can set the initial value in the behavior subject.
BehaviorSubject is a variant of a Subject which has a notion of the current value that it stores and emits to all new subscriptions. This current value is either the item most recently emitted by the source observable or a seed/default value if none has yet been emitted.
A BehaviorSubject holds one value (so we actually need to initialize a default value). When it is subscribed it emits that value immediately. A Subject on the other hand, does not hold a value.
As we know multiple components share the common data and always need updated shared data. In such scenarios most of the time BehaviorSubject is used which acts as a single store to hold updated shared data. BehaviorSubject is both observer and type of observable.
In the world of functional reactive programming, a behavior is a value that changes over time. This is exactly what a BehaviorSubject represents: when you subscribe you get the current value, and then you can continue to observe the changes. See http://en.wikipedia.org/wiki/Functional_reactive_programming.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With