I am trying to create a date scheduler to observe some event. But it does not work. I've looked through
protocol DateScheduler
and it is said that action will take place at currentDate in some methods protocol DateScheduler. I am trying doing this after 10 sec. Below is an example of my custom schedular.
class SomeDateScheduler : DateScheduler {
var currentDate: Date
init() {
self.currentDate = Date(timeIntervalSinceNow: 10)
}
func schedule(after date: Date, action: @escaping () -> Void) -> Disposable? {
print(#function)
print(date)
return nil
}
func schedule(after date: Date, interval: DispatchTimeInterval, leeway: DispatchTimeInterval, action: @escaping () -> Void) -> Disposable? {
print(#function)
print(date)
print(interval)
print(leeway)
return nil
}
func schedule(_ action: @escaping () -> Void) -> Disposable? {
print(#function)
return nil
}
}
and then I create bind to observe event
private func testSchedular() {
let schedular = SomeDateScheduler()
reactive.makeBindingTarget { appDeleg, value in
print("SUCCESS")
print(value)
} <~ signalSchedular.observe(on: schedular)
DispatchQueue.main.async { [observerSchedular] in
observerSchedular.send(value: "Hello World")
observerSchedular.sendCompleted()
}
}
I am doing it into AppDelegate. ObserverSchedular and signalSchedular are global properties. Please, explain to me how to invoke all methods DateScheduler.