Hi,
Is there an Rx property on which we can subscribe for orientation change device ?
Hm, I'm not sure whether there are any NSNotification
But you can observe viewWillTransitionToSize kinda like this:
rx_sentMessage(#selector(UIViewController.viewWillTransitionToSize(_:withTransitionCoordinator:)))
.subscribeNext { (params) in
//Do something here on size class change
}
.addDisposableTo(disposeBag)
Looks a little bit complex. It seems better to
use view.rx_observe(CGRect.self, "frame")
maybe observe UIDeviceOrientationDidChange notification.
NSNotificationCenter.defaultCenter().rx_notification(UIDeviceOrientationDidChangeNotification).subscribeNext {}
Assuming this is resolved :)
The solution is to find a better alternative.
NotificationCenter.default.rx.notification(UIDevice.orientationDidChangeNotification)
.observeOn(MainScheduler.instance)
.subscribe(onNext: { data in
print("data \(data)")
})
.disposed(by: disposeBag)
Most helpful comment
maybe observe UIDeviceOrientationDidChange notification.