Created
June 14, 2020 11:44
-
-
Save zafarivaev/e4b8b473b9b971c656a25af580016670 to your computer and use it in GitHub Desktop.
This file contains 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
import Foundation | |
import Combine | |
var subscriptions = Set<AnyCancellable>() | |
let start = Date() | |
Timer.publish(every: 1.0, on: .main, in: .common) | |
.autoconnect() | |
.map({ (output) in | |
return output.timeIntervalSince(start) | |
}) | |
.map({ (timeInterval) in | |
return Int(timeInterval) | |
}) | |
.sink { (seconds) in | |
print("Seconds: \(seconds)") | |
} | |
.store(in: &subscriptions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment