I need a thirty-second time counter with RxSwift
.
This is a duplicate question but there is no clear answer to the questions
Better approach for existing answer.
let countDown = 15 // 15 seconds
Observable<Int>.timer(.seconds(0), period: .seconds(1), scheduler: MainScheduler.instance)
.take(countDown+1)
.subscribe(onNext: { timePassed in
let count = self.countDown - timePassed
print(count)
}, onCompleted: {
print("count down complete")
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With