ListState
@propertyWrapper
public struct ListState<Object> : DynamicProperty where Object : DynamicObject
A property wrapper type that can read ListPublisher
changes.
-
Creates an instance that observes
ListPublisher
changes and exposes aListSnapshot
value.@ListState var people: ListSnapshot<Person> init(listPublisher: ListPublisher<Person>) { self._people = .init(listPublisher) } var body: some View { List { ForEach(objectIn: self.people) { person in ProfileView(person) } } .animation(.default) }
Declaration
Swift
public init( _ listPublisher: ListPublisher<Object> )
Parameters
listPublisher
The
ListPublisher
that theListState
will observe changes for -
Creates an instance that observes the specified
FetchChainableBuilderType
and exposes aListSnapshot
value.@ListState( From<Person>() .where(\.isMember == true) .orderBy(.ascending(\.lastName)), in: Globals.dataStack ) var people: ListSnapshot<Person> var body: some View { List { ForEach(objectIn: self.people) { person in ProfileView(person) } } .animation(.default) }
Declaration
Swift
public init<B: FetchChainableBuilderType>( _ clauseChain: B, in dataStack: DataStack ) where B.ObjectType == Object
Parameters
clauseChain
a
FetchChainableBuilderType
built from a chain of clauses -
Creates an instance that observes the specified
SectionMonitorBuilderType
and exposes aListSnapshot
value.@ListState( From<Person>() .sectionBy(\.age) .where(\.isMember == true) .orderBy(.ascending(\.lastName)), in: Globals.dataStack ) var people: ListSnapshot<Person> var body: some View { List { ForEach(sectionIn: self.people) { section in Section(header: Text(section.sectionID)) { ForEach(objectIn: section) { person in ProfileView(person) } } } } .animation(.default) }
Declaration
Swift
public init<B: SectionMonitorBuilderType>( _ clauseChain: B, in dataStack: DataStack ) where B.ObjectType == Object
Parameters
clauseChain
a
SectionMonitorBuilderType
built from a chain of clauses -
Creates an instance that observes the specified
From
andFetchClause
s and exposes aListSnapshot
value.@ListState( From<Person>(), Where<Person>(\.isMember == true), OrderBy<Person>(.ascending(\.lastName)), in: Globals.dataStack ) var people: ListSnapshot<Person> var body: some View { List { ForEach(objectIn: self.people) { person in ProfileView(person) } } .animation(.default) }
Declaration
Swift
public init( _ from: From<Object>, _ fetchClauses: FetchClause..., in dataStack: DataStack )
Parameters
from
a
From
clause indicating the entity typefetchClauses
a series of
FetchClause
instances for fetching the object list. AcceptsWhere
,OrderBy
, andTweak
clauses. -
Creates an instance that observes the specified
From
andFetchClause
s and exposes aListSnapshot
value.@ListState( From<Person>(), [ Where<Person>(\.isMember == true), OrderBy<Person>(.ascending(\.lastName)) ], in: Globals.dataStack ) var people: ListSnapshot<Person> var body: some View { List { ForEach(objectIn: self.people) { person in ProfileView(person) } } .animation(.default) }
Declaration
Swift
public init( _ from: From<Object>, _ fetchClauses: [FetchClause], in dataStack: DataStack )
Parameters
from
a
From
clause indicating the entity typefetchClauses
a series of
FetchClause
instances for fetching the object list. AcceptsWhere
,OrderBy
, andTweak
clauses. -
Creates an instance that observes the specified
From
,SectionBy
, andFetchClause
s and exposes a sectionedListSnapshot
value.@ListState( From<Person>(), SectionBy(\.age), Where<Person>(\.isMember == true), OrderBy<Person>(.ascending(\.lastName)), in: Globals.dataStack ) var people: ListSnapshot<Person> var body: some View { List { ForEach(sectionIn: self.people) { section in Section(header: Text(section.sectionID)) { ForEach(objectIn: section) { person in ProfileView(person) } } } } .animation(.default) }
Declaration
Swift
public init( _ from: From<Object>, _ sectionBy: SectionBy<Object>, _ fetchClauses: FetchClause..., in dataStack: DataStack )
-
Creates an instance that observes the specified
From
,SectionBy
, andFetchClause
s and exposes a sectionedListSnapshot
value.@ListState( From<Person>(), SectionBy(\.age), [ Where<Person>(\.isMember == true), OrderBy<Person>(.ascending(\.lastName)) ], in: Globals.dataStack ) var people: ListSnapshot<Person> var body: some View { List { ForEach(sectionIn: self.people) { section in Section(header: Text(section.sectionID)) { ForEach(objectIn: section) { person in ProfileView(person) } } } } .animation(.default) }
Declaration
Swift
public init( _ from: From<Object>, _ sectionBy: SectionBy<Object>, _ fetchClauses: [FetchClause], in dataStack: DataStack )
-
Declaration
Swift
public mutating func update()