What , if anything right now, would be considered ...
# compose
j
What , if anything right now, would be considered Compose's equivalent of SwiftUI's
@Binding
?
k
Why would you use that instead of a state class for the entire screen? That seems like a shared ambient variable aka a global from the description of it.. https://www.hackingwithswift.com/quick-start/swiftui/what-is-the-binding-property-wrapper
j
Hmm, I guess the way @State is managed in SwiftUI vs Compose's concept of state may mean @Binding isn't needed/applicable in Compose
r
I'd say the equivalent to Binding in SwiftUI is MutableState. Swift is different here because they are using value types for so much. Because SwiftUI's
State
is a value type they, can't just pass a reference to it, so
Binding
is effectively that reference. While in Compose you just pass the MutableState down to nested Composables, either directly, or as the get/set pair.
👍 2
j
I also wonder to what extent proper use of "state hoisting" avoids need for this approach as well
2