Last active
December 11, 2023 17:08
-
-
Save krzysztofzablocki/61ede7491b1875e86cbe3a843352c6f4 to your computer and use it in GitHub Desktop.
Breaking isolation context bug
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 SwiftUI | |
@Observable @MainActor | |
final class ViewModel { | |
var name: String { "Foo" } | |
} | |
class ObservableFoo: ObservableObject {} | |
struct ContentView: View { | |
@Bindable var viewModel: ViewModel | |
// Comment this out to see the error pop up when accessing the `viewModel.name` | |
// property. (whether it's properly injected on just like this does not matter) | |
@ObservedObject private var foo = ObservableFoo() | |
var body: some View { | |
VStack { | |
Text(text) | |
} | |
.padding() | |
} | |
private var text: String { | |
viewModel.name | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment