dorche
11/13/2025, 8:49 AMdorche
11/13/2025, 8:50 AMstruct ExampleView: View {
let viewModel = SharedViewModel()
var body: some View {
// Observing multiple flows with attached initial values, only requiring a single view closure for content.
Observing(viewModel.counter.withInitialValue(0), viewModel.toggle) { counter, toggle in
Text("Counter: \(counter), Toggle: \(toggle)")
}
}
}
What is the recommended way to trigger a function (i.e. navigation) when the counter reaches 100 for example ?Filip Wiesner
11/13/2025, 8:53 AM.task(id) {} modifier in SwiftUI which starts a task when the id changes. It's very similar to LaunchedEffect in Composedorche
11/13/2025, 8:53 AMFilip Wiesner
11/13/2025, 8:54 AMonChange looks good as welldorche
11/13/2025, 8:55 AMFilip Wiesner
11/13/2025, 8:56 AM