3

In the API documentation it says

Arguments

  1. observer (Observer): The observer used to send messages to the subject.
  2. observable (Observable): The observable used to subscribe to messages sent from the subject.

But isn't the concept backwards in that the observer is supposed to be receiving/handling messages emitted from the subject, and the observable is what the subject would be subscribed to? The API doc and the getting started with subjects doc don't seem consistent.

Community
  • 1
  • 1
solstice333
  • 3,399
  • 1
  • 31
  • 28

1 Answers1

1

Your question is already answered here: Subjects created with Subject.create can't unsubscribe

Subject.create is a static method that just connects the Observable with an observer. No instance of Subject is involved.

What you're describing looks more like multicasting so maybe have a look at multicast() operator or its derivatives.

Also see:

martin
  • 93,354
  • 25
  • 191
  • 226
  • Ok, sounds simple enough, but if Subject.create() is just connecting the given Observable to the given Observer, why does the API doc for the Subject.create() arguments even mention a subject entity as some sort of proxy? And why does it mention an Observer as "sending messages" and an Observable as "subscribing to messages"? Is the doc simply wrong? – solstice333 Jun 13 '17 at 00:03
  • 1
    @solstice333 You're referring to RxJS 4, which is old. What I wrote here refers to RxJS 5. – martin Jun 13 '17 at 06:34