I have a switcher that changes the app theme.
switchButton.rx
.controlEvent(.valueChanged)
.withLatestFrom(themeService.typeStream)
.map { $0 == .dark ? .light : .dark }
.bind(to: themeService.switcher)
.disposed(by: disposeBag)
I want to add another custom function when an app theme changes. Thanks
CodePudding user response:
You're allowed to subscribe to an Observable more than once.
let theme = switchButton.rx
.controlEvent(.valueChanged)
.withLatestFrom(themeService.typeStream)
.map { $0 == .dark ? .light : .dark }
.share()
theme
.bind(to: themeService.switcher)
.disposed(by: disposeBag)
theme
.bind(to: anotherCustomFunction)
.disposed(by: disposeBag)