Last active
March 28, 2021 20:27
-
-
Save gtokman/262283f0182855df422a2099237d7957 to your computer and use it in GitHub Desktop.
subscribe vs receive
This file contains hidden or 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
["hello world"] | |
.publisher | |
.subscribe(on: DispatchQueue.global(qos: .background)) // 1 | |
.map { string -> String in | |
print("Is main thread in map:", Thread.isMainThread) | |
return string | |
} | |
.breakpoint(receiveOutput: { str in | |
print("current str:", str) | |
return Thread.isMainThread // if main thread, breakpoint | |
}) | |
.print("debug") | |
.receive(on: DispatchQueue.main) // 2 | |
.sink { str in | |
print("Is main thread in sink:", Thread.isMainThread) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment