Created
October 24, 2025 19:54
-
-
Save ldct/5943a5500f475a9054b40aeb4bcfb54e to your computer and use it in GitHub Desktop.
Swift playgrounds
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
| //: 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