Good afternoon (o;
After two days learning Swift/SwiftUI I have a little app running that retrieves JSON data from our online shop with a TabView showing:
- Stats for today/week/month etc...
- Last 2000 orders in a List with a detailed view
I use the .onAppear() method to fetch the JSON for the orders list but also .refreshable to update it on demand:
.refreshable {
fetch.reload()
}
.onAppear {
self.fetch.reload()
}
But this has the side effect that when I open the order details view and go back, that the JSON is reloaded.
Is there a better approach to have the view initialized on startup? Or should I just add an init() method to the JSON fetching model which in turn calls reload()?
thanks in advance richard