Rx Subject Vs GoF Subject

82 views Asked by At

How the Rx Subject and the Subject in GandOfFour Observer pattern are different?

1

There are 1 answers

0
Shlomo On BEST ANSWER

There's some overlap:

  • GoF Subject: Subscribe handler, unsubscribe handler, send notification to handlers

  • Rx Observable: Subscribe handler of type T, (implicitly unsubscribe via subscription disposable)

  • Rx Observer: Handler that receives notification of type T (or error, or end)
  • Rx Subject: Observable + Observer for some type T

So they support the same basic operations. I would assume Rx Team chose their name based on GoF usage. Rx Team though clearly wanted to split the functions of 'Subject' into sender and receiver: The emphasis in Rx is observables, not subjects.