State
@propertyWrapper
public class State<Value> : TypeErasedState
A property wrapper type that can read and write a value managed by SwiftWeb.
SwiftWeb manages the storage of any property you declare as a state. When the state value changes, the view invalidates its appearance and recomputes the body. Use the state as the single source of truth for a given view.
A State instance isn’t the value itself; it’s a means of reading and writing the value. To access a state’s underlying value, use its variable
name, which returns the wrappedValue
property value.
You should only access a state property from inside the view’s body, or from methods called by it.
-
The underlying value referenced by the state variable.
Declaration
Swift
public var wrappedValue: Value { get set }
-
Creates the state with an initial wrapped value.
Declaration
Swift
public init(wrappedValue: Value)
-
A binding to the state value.
Declaration
Swift
public var binding: Binding<Value> { get }