Will there be any difference in running a function that is not marked as async and running it inside a Task
?
.onChange(of: callState.current) { state in
viewModel.changeNavigation(title: state.controllerTitle) // 1 - outside
Task {
viewModel.changeNavigation(title: state.controllerTitle) // 2 - inside
Task.detached(priority: .background) {
await viewModel.audit(state: state)
}
}
}
onChange
is called from MainActor
(SwiftUI View).
Both options are executed on the main thread.
Is there any difference in the performance exerted on the main thread and UI?