Created
January 25, 2022 09:03
-
-
Save eunjin3786/2e3cdba82a7a9938ad1eec47cb747faa 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
let observable = Observable<Int>.interval(.seconds(1), scheduler: MainScheduler.instance) | |
Task { | |
do { | |
for try await value in observable.values { | |
print("Got a value:", value) | |
} | |
} catch { | |
print("Got an error:", error) | |
} | |
} | |
// Prints | |
Got a value: 0 | |
Got a value: 1 | |
Got a value: 2 | |
Got a value: 3 | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment