Documentation for the topic is sparse and it's hard to discover an "entry-point" there.
Semantics differ according to the type of subjects. I will divide them in two kinds : vanilla (
Rx.Subject), and special-purpose subjects (the other three). The special-purpose subjects share part of the semantics of the vanilla subject with a few caveats due to their specialization (for instance, completion/reconnection behaviour).
Vanilla Rx.Subject semantics
disposehandler on their prototype). That means, among other things, they have:
.asObservable()) if need be
disposeing a subject will unsubscribe all observers and release resources.
I quote a key aspect of Rxjs contract and grammar :
This grammar allows observable sequences to send any amount (0 or more) of onNext messages to the subscribed observer instance, optionally followed by a single success (onCompleted) or failure (onError) message.
a vanilla subject (created with
new Rx.Subject()) implements that grammar : when
onCompleted has been called once, all subsequent calls to
onNext are ignored. Second call of
onCompleted on the same observer is also ignored. If an observer subscribes to the observable side of the subject, its
onComplete callback will immediately be called (http://jsfiddle.net/cLf6Lqsn/1/).
Returns a subject which connects its observer to its observable (jsfiddle). This example is taken from the official documentation and portrays how to use subjects as proxies. The subject is subscribed to a source (observer side), and is also listened on by observers (observable side). Any call to
onNext (observer side) results in the observable side calling
onNext with the same value for each of its observers.
Creates a subject from the specified observer and observable. Those two are not necessarily connected. A good example can be seen in the implementation of
Rx.Dom.fromWebSocket which returns a subject used to send and receive data from a socket. The observer side of the subject sends data to the socket. The observable side is used to listen on incoming data from the socket. Also, a subject created this way does NOT have a
Specialized Rx.Subject semantics
reactivex.iodocumentation covers pretty well most of the semantics of the specialized subjects.
Hopefully I did not get too much wrong. I'll be happy to be corrected. Last note, this should be valid for RxJS v4.
For a detailed explanation of the behaviour of cold/hot observables, one can refer to : Hot and Cold observables : are there 'hot' and 'cold' operators?
©2020 All rights reserved.