# ListState

    @propertyWrapper
    public struct ListState<Object> : DynamicProperty where Object : DynamicObject

A property wrapper type that can read `ListPublisher` changes.

### Public

- `init(_:)`

  Creates an instance that observes `ListPublisher` changes and exposes a `ListSnapshot` 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 the `ListState` will observe changes for

- `init(_:in:)`

  Creates an instance that observes the specified `FetchChainableBuilderType` and exposes a `ListSnapshot` 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

- `init(_:in:)`

  Creates an instance that observes the specified `SectionMonitorBuilderType` and exposes a `ListSnapshot` 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

- `init(_:_:in:)`

  Creates an instance that observes the specified `From` and `FetchClause`s and exposes a `ListSnapshot` 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 type
  `fetchClauses` | a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.

- `init(_:_:in:)`

  Creates an instance that observes the specified `From` and `FetchClause`s and exposes a `ListSnapshot` 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 type
  `fetchClauses` | a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.

- `init(_:_:_:in:)`

  Creates an instance that observes the specified `From`, `SectionBy`, and `FetchClause`s and exposes a sectioned `ListSnapshot` 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
      )

  #### Parameters

  `from` | a `From` clause indicating the entity type
  `sectionBy` | a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
  `fetchClauses` | a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.

- `init(_:_:_:in:)`

  Creates an instance that observes the specified `From`, `SectionBy`, and `FetchClause`s and exposes a sectioned `ListSnapshot` 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
      )

  #### Parameters

  `from` | a `From` clause indicating the entity type
  `sectionBy` | a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
  `fetchClauses` | a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.

### DynamicProperty

- `update()`

  #### Declaration

  Swift

      public mutating func update()