environment(_:_:)

Sets the value of a TaskLocal for the duration of rendering the content.

Environment.swift:72
func environment<T>(_ taskLocal: TaskLocal<T>, _ value: T) -> _ModifiedTaskLocal<T, Self> where T : Sendable

The value can be accessed using the Environment property wrapper. Elementary uses task-locals as the underlying storage system for environment variables.

enum Values {
    @TaskLocal static var myNumber = 0
}
div {
    MyNumber()
        .environment(Values.$myNumber, 15)
}