ListReader
public struct ListReader<Object, Content, Value> : View where Object : DynamicObject, Content : View
A container view that reads list changes in a ListPublisher
-
Creates an instance that creates views for
ListPublisherchanges.let people: ListPublisher<Person> var body: some View { List { ListReader(self.people) { listSnapshot in ForEach(objectIn: listSnapshot) { person in ProfileView(person) } } } .animation(.default) }Declaration
Swift
public init( _ listPublisher: ListPublisher<Object>, @ViewBuilder content: @escaping (ListSnapshot<Object>) -> Content ) where Value == ListSnapshot<Object>Parameters
listPublisherThe
ListPublisherthat theListReaderinstance uses to create views dynamicallycontentThe view builder that receives an
ListSnapshotinstance and creates views dynamically. -
Creates an instance that creates views for
ListPublisherchanges.let people: ListPublisher<Person> var body: some View { ListReader(self.people, keyPath: \.count) { count in Text("Number of members: \(count)") } }Declaration
Swift
public init( _ listPublisher: ListPublisher<Object>, keyPath: KeyPath<ListSnapshot<Object>, Value>, @ViewBuilder content: @escaping (Value) -> Content )Parameters
listPublisherThe
ListPublisherthat theListReaderinstance uses to create views dynamicallykeyPathA
KeyPathfor a property in theListSnapshotwhose value will be sent to the viewscontentThe view builder that receives the value from the property
KeyPathand creates views dynamically.
-
Declaration
Swift
public var body: some View { get }
View on GitHub
ListReader Structure Reference