Last active
April 15, 2021 16:46
-
-
Save mbrandonw/863c2a20a11ab9704acce97cac19bf5d to your computer and use it in GitHub Desktop.
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
import Combine | |
class VM: ObservableObject { | |
@Published var int = 0 | |
} | |
let vm = VM() | |
_ = vm.$int.sink { value in | |
print("Current value", value) | |
print("Previous value", vm.int) | |
} | |
vm.int = 1 | |
// => Current value 1 | |
// => Previous value 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment