Skip to content

Instantly share code, notes, and snippets.

@OskarGroth
Last active November 12, 2020 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OskarGroth/43857077ecdbe770f57bb6c93cab7ad2 to your computer and use it in GitHub Desktop.
Save OskarGroth/43857077ecdbe770f57bb6c93cab7ad2 to your computer and use it in GitHub Desktop.
class ObjA {
var isOn = false
}
struct ContentView: View {
// Because this is not an observed object, the UI in this view should theoretically never update
let obj = ObjA()
var body: some View {
print("Refreshed body")
return VStack {
Toggle("Test", isOn: Binding(
get: { obj.isOn },
set: {
obj.isOn = $0
}
))
.toggleStyle(SwitchToggleStyle())
Toggle("Test", isOn: Binding(
get: { obj.isOn },
set: {
obj.isOn = $0
}
))
}
.padding(30)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment