Discussion 議論
Don’t call this method directly. SwiftUI calls it when you call the Refresh
structure that you get from the Environment
:
struct RefreshableView: View {
private var refresh (\.refresh)
var body: some View {
Button("Refresh") {
Task {
await refresh?() // Implicitly calls refresh.callAsFunction()
}
}
.disabled(refresh == nil)
}
}
For information about how Swift uses the call
method to simplify call site syntax, see Methods with Special Names in The Swift Programming Language. For information about asynchronous operations in Swift, see Concurrency.