-
-
Save jasdev/f0730d645025ffb5a385766159f34f22 to your computer and use it in GitHub Desktop.
Check `untilOutputFrom`’s demand count.
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 Combine | |
import PlaygroundSupport | |
var subscriptions = Set<AnyCancellable>() | |
[1, 2, 3] | |
.publisher | |
.prefix( | |
untilOutputFrom: Just(4) | |
.print() /// (1) To log out lifecycle events. | |
).sink(receiveValue: { print($0) }) | |
.store(in: &subscriptions) | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
/// (2) Output. Note that only a max of one value is requested from `Just(4)`. | |
/// ```none | |
/// receive subscription: (Just) | |
/// request max: (1) | |
/// receive value: (4) | |
/// receive cancel | |
/// receive finished | |
/// ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment