Hooks
- useBindable@Bindable: tracks reads like useObservable, and gives a Binding to each property under $name: <TextField text={book.$title} /.
- useBindingCreates a Binding object that can be used to read and write to a value. Components can recieve a binding as a prop and can handle the logic of getting and setting the value from inside the component.
- useEnvironment@Environment(Model.self): reads the Observable an ancestor supplied with .environment(model). The component re-renders only when a property it read changes. With { optional: true }, like Model?.self, a missing object gives null instead of throwing.
- useEnvironmentObject@EnvironmentObject: reads the object an ancestor supplied with .environmentObject(object), and re-renders the component whenever it changes.
- useFocusedObject@FocusedObject: the object of this type that the focused view, one of its ancestors, or the focused scene publishes with focusedObject or focusedSceneObject, or null. The component re-renders when focus moves and when the object changes.
- useFocusedValue@FocusedValue(Model.self): the Observable of this type that the focused view, one of its ancestors, or the focused scene publishes with focusedValue or focusedSceneValue, or null. The component re-renders when focus moves and when a property it read changes.
- useObservableReads an Observable the way a SwiftUI body does: the component re-renders only when a property it read changes. Pass the object from props, state or anywhere else.
- useObservedObject@ObservedObject: re-renders the component whenever the object changes.
- useStateObject@StateObject: creates the object once for the component's lifetime, and observes it.
Functions
SwiftUI functions
- createNavigationPathStarts a SwiftUI NavigationPath. Each call returns a new value, as compose() does.
- createPathStarts a SwiftUI Path. Each call returns a new value, as compose() does.
- createScrollPositionStarts a SwiftUI ScrollPosition. Each call returns a new value, as compose() does.
- createTabViewCustomizationStarts a SwiftUI TabViewCustomization. Each call returns a new value, as compose() does.
- createTransactionStarts a SwiftUI Transaction. Each call returns a new value, as compose() does.
- withAnimationReturns the result of recomputing the view's body with the provided animation.
- withTransactionExecutes a closure with the specified transaction key path and value and returns the result.
Types
- ObservableThe JavaScript @Observable class: subclass it, and a component re-renders only when a property it read changes (useObservable, useBindable, useEnvironment).
- ObservableObjectThe JavaScript ObservableObject: subclass it, and any change to its properties re-renders every component observing it (useStateObject, useObservedObject, useEnvironmentObject).
- ScalarA number SwiftUI decides. rect.width.times(0.5).plus(8) is rect.width 0.5 + 8 in Swift. Comparisons give a Scalar of 1 or 0, for select.
- Scalars