ReactiveX / RxSwift

Reactive Programming in Swift
MIT License
24.37k stars 4.17k forks source link

Why not adopt ObserverType for Relays? #2502

Closed geonu1109 closed 1 year ago

geonu1109 commented 1 year ago

Relays such as BehaviorRelay and PublishRelay included in RxRelay play a role in accepting and emitting values like RxSwift’s Subject, right? Although Relay can not handle all RxSwift events, adopting ObserverType will bring convenience to various implementations. Some people may be concerned about how to handle error or complete events, but I think we can do that by following the way Binder, which had the same problem, adopted ObserverType. What do you think?

danielt1263 commented 1 year ago

Subjects [and Relays] provide a convenient way to poke around Rx, however they are not recommended for day to day use. -- Introduction To Rx

I'm not sure it's a good idea to make something that isn't recommended for day to day use, more convenient.

freak4pc commented 1 year ago

Hey @geonu1109, We had a lengthy discussion about this here: https://github.com/ReactiveX/RxSwift/pull/1551#issuecomment-359357438

I suggest reading it and commenting here again if you have any questions./

geonu1109 commented 1 year ago

@freak4pc Thanks for the good discussion. Considering type safety, it would be correct not to add it. There is already an alternative called Subjects. To say that Binders are dangerous at runtime would be a departure from the current discussion.