Leaving a loading screen
When the user enters the detail screen, it calls an API like this and shows the data.
final class DetailViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
api.fetchDetail(id: id) { result in
self.render(result)
}
}
}The interviewer asks: "What happens if the user taps back before the response arrives?" Explain the problems this code can cause, and how you'd keep the request for a screen the user left from going to waste.