Skip to content

Instantly share code, notes, and snippets.

@mbrandonw
Last active April 15, 2021 16:46
Show Gist options
  • Save mbrandonw/863c2a20a11ab9704acce97cac19bf5d to your computer and use it in GitHub Desktop.
Save mbrandonw/863c2a20a11ab9704acce97cac19bf5d to your computer and use it in GitHub Desktop.
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