RxViewController
RxViewController copied to clipboard
isVisible does not always work if not subscribed immediately
Hello,
thank you very much for this great Pod. I think there might be an issue with UIViewController isVisible property.
For instance, if this Observable is not subscribed to before the base method viewWillAppear() is invoked for the first, time, then isVisible will emit nothing instead of emitting true.
My point is that isVisible should behave like a state, not just like a combination of events: any time some observer subscribes to it, it should immediately get an event true or false.
To do so, there would be two things to do:
- using a
.share(replay: 1, scope: .forever)and a.startWith(false). - subscribing it internally, so that is begins immediately to listen for the
viewDidAppearObservableandviewWillDisappearObservable, even if externally there are no subscribers to it. Maybe using a.publish()and.connect(), or using an internalDisposeBagproperty.
Thank you very much, I would be pleased to know your opinion on this.
P.S. : And to go a bit further, it might be interesting to expose it as a Driver instead of an Observable.