Skip to content

Instantly share code, notes, and snippets.

@ldct
Created October 24, 2025 19:54
Show Gist options
  • Save ldct/5943a5500f475a9054b40aeb4bcfb54e to your computer and use it in GitHub Desktop.
Save ldct/5943a5500f475a9054b40aeb4bcfb54e to your computer and use it in GitHub Desktop.
Swift playgrounds
//: A UIKit based Playground for presenting user interface
import Combine
struct ViewState {
var a: Int
var b: Int
}
class MyClass {
@Published var viewstate = ViewState(a: 0, b: 0)
var cancellables: Set<AnyCancellable> = []
init() {
$viewstate.sink { viewState in
print(viewState)
}.store(in: &cancellables)
viewstate.a += 1
viewstate.a += 1
}
}
let myClass = MyClass()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment