Compose SwiftUIv0.4.0
esc
GuideAPIGitHub
View modifier

onChange(_:)

A view modifier that maps SwiftUI's onChange.

iOS 17.0+macOS 14.0+tvOS 17.0+watchOS 10.0+
fun Modifier.onChange(value: Any, perform: (Any) -> Unit): Modifier

Overview

Modifier.onChange(value = value, perform = { value -> })

This is the Kotlin form of SwiftUI View.onChange(of:perform:): SwiftUI documentation. In Swift it reads:

nonisolated func onChange<V>(of value: V, perform action: @escaping (V) -> Void) -> some View where V : Equatable

Topics

Overloads

fun Modifier.onChange(value: Any, initial: Boolean = false, action: () -> Unit): Modifier
SwiftUI View.onChange(of:initial:_:)
fun Modifier.onChange(value: Any, perform: (Any) -> Unit): Modifier
SwiftUI View.onChange(of:perform:)