Added bind(to:) methods for PublishRelay and BehaviorRelay. Added relevant tests for binding.#1470
Conversation
…evant tests for binding.
Generated by 🚫 Danger |
Observer can also receive
And if sending error to relay class should be prohibited, |
|
@inamiy It was not possible to use
|
|
@Biboran Yes, as you said "quite ok to assume", we can go unsafe way to let any observables bind to relay classes, but that's almost the same as going back to previous |
|
I think that the most ideal solution would be if Swift allowed generic types with default generic parameters: ... and parametrized error throwing. Then we could specify: Until then the only classes that have some guarantees are What should we do in ideal case is clear. What should we do in this case isn't so much IMHO. I've moved extensions that enable binding of Binding of any observable that is finite or errors out is wrong IMHO, but right now we don't have compile time guarantees regarding those properties on |
|
That makes sense. I just read a bit about the intention of relays and recognized that binding Observables that might error out or complete is a terrible idea for a What might make sense is binding a |
|
@kzaher For better typing, https://gist.github.com/inamiy/de1a495ec198b7f9b504b9598999e6ed |
|
Hi @inamiy , yeah, there are multiple ways how one could model observables and events, and each has its benefits and downsides. We've so far used compositional approach because it was most practical and most backwards compatible. We could maybe figure out some even more typesafe approach, but this worked ok so far. So far we don't have I would like to find some nice way that provides more flexibility regarding enabling/disabling certain types of events, but unfortunately haven't figured out anything that pleases me. I think that solution that you've proposed also unfortunately has some issues, but yeah, maybe there is some nice solution out there. |
|
@kzaher Since
I think as this because I see many developers adding the similar custom extensions like this PR to bring back to What do you think? |
|
Bumped into this and 👍 for the idea of public func neverComplete() -> Observable<E> {
return concat(Observable.never())
}but have no guarantee to be called before binding to Subjects. Another thing is, why there is implementation of drive to BehaviourRelay in |
Yes, I agree. It's better to at least have those extensions in one place.
I think it's best to not add I doesn't complete, but does not sending
Because of different sharing strategies. |
Binding implementation related to #1466.
Off-topic: why PublishRelay and BehaviorRelay don't conform to ObserverType?