Open
Description
Name and description
I have a timer
Observable and I need to pause it with one condition: when it'll resume it'll continue to emit elements from an element, which be paused with initial delay.
Example of use
My code:
let timerActiveSubject = BehaviorSubject<Bool>(value: true)
let timer = Observable<Int>
.timer(0, period: 1, scheduler: MainScheduler.instance)
.pausable(timerActiveSubject)
timer
.subscribe(onNext: { (sec) in
debugPrint("Timer tick: \(sec)")
})
.disposed(by: self.bag)
...
timerActiveSubject.onNext(false)
...
// When I send `true` element to subject, timer observable resume,
// but emitted all leaved elements in moment without delay.
timerActiveSubject.onNext(true)