-
-
Save laevandus/b4ded21951edc15e032f54b496c37315 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
@Published var state1 = "0" | |
@Published var state2 = "a" | |
func combineLatestExample() { | |
$state1.combineLatest($state2) | |
.sink { value in | |
print("sink", value) | |
} | |
.store(in: &cancellables) | |
print("will change state1 to 1") | |
state1 = "1" | |
print("will change state1 to 2") | |
state1 = "2" | |
print("will change state2 to b") | |
state2 = "b" | |
print("will change state1 to 3") | |
state1 = "3" | |
print("will change state2 to c") | |
state2 = "c" | |
} | |
/* example | |
sink ("0", "a") | |
will change state1 to 1 | |
sink ("1", "a") | |
will change state1 to 2 | |
sink ("2", "a") | |
will change state2 to b | |
sink ("2", "b") | |
will change state1 to 3 | |
sink ("3", "b") | |
will change state2 to c | |
sink ("3", "c") | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment