UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Loading indicator while Async Dynamic List loads?

Forums > SwiftUI

Hey everyone,

So I have a dynamic list that pulls data from MongoDB, and it typically takes around 2-3 seconds to load with just 5 objects or so. I want to either:

a) Show a placeholder row in case there are lots of objects to load b) Show a loading indicator while the list fully loads

I've been able to use loading indicators before through waiting for a Dispatch Queue to finish for other functions, but I can't seem to figure out how to do the above with objects loading in the list.

The data I fetch is retrieved through an ObservableObject (RealmModel), and for simplicity's sake the list looks like this:

@ObservedObject var getrealmdata = RealmModel()
@EnvironmentObject var plantdata: RealmModel
@EnvironmentObject var plantmodel: Plant

List {
                    ForEach(getrealmdata.plantarray) { plants in
                        NavigationLink(destination: FloraPodDetailView(plantdata: plants, plantsensor: self.plantsensor)) {
                        PlantSensorRealmRow(plantsensor: self.plantsensor, plantdata: plants)
                        }
                    }
                }

3      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.