MΓ³dulo 10 Β· Bookings: Forms & the Full Loop β LecciΓ³n 2 de 4 Β· ~8 min
Submitting: Happy Path, Sad Path
What the Book button actually does
Button("Book") { Task { await submit() } } β the Task { } wrapper is the same bridge you used in Module 8's login button: button taps are synchronous, networking is async, and Task jumps the gap.
submit() has to juggle four responsibilities: flip the UI into its busy state, build the request, hit the network, and then take one of two exits β success (close the sheet, tell the presenter) or failure (show an error, keep the user's input). Here it is, whole: