0

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

wonderful world
  • 10,969
  • 20
  • 97
  • 194

1 Answers1

2

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.

Shlomo
  • 14,102
  • 3
  • 28
  • 43