Search code examples
javascriptrxjsobserver-patternobserversreactivex

Rx.Subject.create(observer, observable) confusion


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.


Solution

  • 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: