Closed rpassis closed 2 years ago
The conversion here doesn't necessarily make sense. "Casting" a subject to a relay like this loses all events except for value (next) events without any fallbacks, which is a bit strange. It seems to me the right thing to do is make the subject a relay from the get-go if that's the contract you're trying to work with.
I find both
Passthrough
andCurrentValue
relays pretty useful however they require that the entire stack adopts that convention because there is no way to currently convert an existingSubject
to aRelay
.This is useful when you are for example adding a new scene/feature which takes a subject from a previous screen as a way to communicate some user action.
For simplicity here's an example:
Since the backing storage for both
Relay
types are their corresponding (private) subjects, it would be useful to add initializers to theRelay
types that take an existing subject as the backing storage.Is this something you'd be willing to accept as a contribution? Let me know and I'd be happy to get a PR ready. AFAICT We should be able to overload the existing initializer so no breaking changes involved either.
Let me know what you think! Rog