Last active
March 4, 2019 17:48
-
-
Save pzmudzinski/ff459845a734b84a50e299c479417b7f to your computer and use it in GitHub Desktop.
delay & map?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let errorOrCompletedColor = viewModel.triggerDiscount | |
.executionObservables | |
.flatMapLatest { $0 } | |
.materialize() | |
.map { event -> UIColor in | |
switch event { | |
case .error(_): | |
return TriggerDiscountView.errorColor | |
case .next(_), .completed: | |
return TriggerDiscountView.successColor | |
} | |
} | |
errorOrCompletedColor | |
.bind(to: indicatorView.rx.backgroundColor) | |
.disposed(by: bag) | |
errorOrCompletedColor | |
.delay(1.0, scheduler: MainScheduler.instance) | |
.map { _ -> UIColor in .clear } | |
.bind(to: indicatorView.rx.backgroundColor) | |
.disposed(by: bag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment