ObservedSectionedResults
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@propertyWrapper
@MainActor
public struct ObservedSectionedResults<Key, ResultType> : DynamicProperty, BoundCollection where Key : _Persistable, Key : Hashable, ResultType : KeypathSortable, ResultType : RealmFetchable, ResultType : _ObservedResultsValue, ResultType : Identifiable
A property wrapper type that represents a sectioned results collection.
The sectioned results use the realm configuration provided by
the environment value realmConfiguration
if configuration is not set in the initializer.
Given @ObservedSectionedResults var v in SwiftUI, $v refers to a BoundCollection.
-
Declaration
Swift
public typealias Element = ResultType -
Stores an NSPredicate used for filtering the SectionedResults. This is mutually exclusive to the
whereparameter.Declaration
Swift
@State @MainActor public var filter: NSPredicate? { get nonmutating set } -
Stores a type safe query used for filtering the SectionedResults. This is mutually exclusive to the
filterparameter.Declaration
-
Initialize a
ObservedSectionedResultsstruct for a givenProjectiontype.Note
The primary sort descriptor must be responsible for determining the section key.
Declaration
Swift
@MainActor public init<ObjectType: ObjectBase>(_ type: ResultType.Type, sectionKeyPath: KeyPath<ResultType, Key>, sortDescriptors: [SortDescriptor] = [], filter: NSPredicate? = nil, keyPaths: [String]? = nil, configuration: Realm.Configuration? = nil) where ResultType: Projection<ObjectType>, ObjectType: ThreadConfinedParameters
typeObserved type
sectionKeyPathThe keyPath that will produce the key for each section. For every unique value retrieved from the keyPath a section key will be generated.
sortDescriptorsA sequence of
SortDescriptors to sort by.filterObservations will be made only for passing objects. If no filter given - all objects will be observed
keyPathsOnly properties contained in the key paths array will be observed. If
nil, notifications will be delivered for any property change on the object. String key paths which do not correspond to a valid a property will throw an exception.configurationThe
Realm.Configurationused when creating the Realm. If empty the configuration is set to thedefaultConfiguration -
Initialize a
ObservedSectionedResultsstruct for a givenProjectiontype.Note
The primary sort descriptor must be responsible for determining the section key.
Declaration
Swift
@MainActor public init<ObjectType: ObjectBase>(_ type: ResultType.Type, sectionBlock: @escaping ((ResultType) -> Key), sortDescriptors: [SortDescriptor] = [], filter: NSPredicate? = nil, keyPaths: [String]? = nil, configuration: Realm.Configuration? = nil) where ResultType: Projection<ObjectType>, ObjectType: ThreadConfinedParameters
typeObserved type
sectionBlockA callback which returns the section key for each object in the collection.
sortDescriptorsA sequence of
SortDescriptors to sort by.filterObservations will be made only for passing objects. If no filter given - all objects will be observed
keyPathsOnly properties contained in the key paths array will be observed. If
nil, notifications will be delivered for any property change on the object. String key paths which do not correspond to a valid a property will throw an exception.configurationThe
Realm.Configurationused when creating the Realm. If empty the configuration is set to thedefaultConfiguration -
Initialize a
ObservedSectionedResultsstruct for a givenObjectorEmbeddedObjecttype.Note
The primary sort descriptor must be responsible for determining the section key.
Declaration
Swift
@MainActor public init(_ type: ResultType.Type, sectionKeyPath: KeyPath<ResultType, Key>, sortDescriptors: [SortDescriptor] = [], filter: NSPredicate? = nil, keyPaths: [String]? = nil, configuration: Realm.Configuration? = nil) where ResultType: ObjectParameters
typeObserved type
sectionKeyPathThe keyPath that will produce the key for each section. For every unique value retrieved from the keyPath a section key will be generated.
sortDescriptorsA sequence of
SortDescriptors to sort by.filterObservations will be made only for passing objects. If no filter given - all objects will be observed
keyPathsOnly properties contained in the key paths array will be observed. If
nil, notifications will be delivered for any property change on the object. String key paths which do not correspond to a valid a property will throw an exception.configurationThe
Realm.Configurationused when creating the Realm. If empty the configuration is set to thedefaultConfiguration -
Initialize a
ObservedSectionedResultsstruct for a givenObjectorEmbeddedObjecttype.Note
The primary sort descriptor must be responsible for determining the section key.
Declaration
Swift
@MainActor public init(_ type: ResultType.Type, sectionBlock: @escaping ((ResultType) -> Key), sortDescriptors: [SortDescriptor] = [], filter: NSPredicate? = nil, keyPaths: [String]? = nil, configuration: Realm.Configuration? = nil) where ResultType: ObjectParameters
typeObserved type
sectionBlockA callback which returns the section key for each object in the collection.
sortDescriptorsA sequence of
SortDescriptors to sort by.filterObservations will be made only for passing objects. If no filter given - all objects will be observed
keyPathsOnly properties contained in the key paths array will be observed. If
nil, notifications will be delivered for any property change on the object. String key paths which do not correspond to a valid a property will throw an exception.configurationThe
Realm.Configurationused when creating the Realm. If empty the configuration is set to thedefaultConfiguration -
Initialize a
ObservedSectionedResultsstruct for a givenObjectorEmbeddedObjecttype.Note
The primary sort descriptor must be responsible for determining the section key.
Declaration
Swift
@MainActor public init(_ type: ResultType.Type, sectionBlock: @escaping ((ResultType) -> Key), sortDescriptors: [SortDescriptor] = [], where: ((Query<ResultType>) -> Query<Bool>)? = nil, keyPaths: [String]? = nil, configuration: Realm.Configuration? = nil) where ResultType: ObjectParameters
typeObserved type
sectionBlockA callback which returns the section key for each object in the collection.
sortDescriptorsA sequence of
SortDescriptors to sort by.whereObservations will be made only for passing objects. If no type safe query is given - all objects will be observed.
keyPathsOnly properties contained in the key paths array will be observed. If
nil, notifications will be delivered for any property change on the object. String key paths which do not correspond to a valid a property will throw an exception.configurationThe
Realm.Configurationused when creating the Realm. If empty the configuration is set to thedefaultConfiguration -
Initialize a
ObservedSectionedResultsstruct for a givenObjectorEmbeddedObjecttype.Note
The primary sort descriptor must be responsible for determining the section key.
Declaration
Swift
@MainActor public init(_ type: ResultType.Type, sectionKeyPath: KeyPath<ResultType, Key>, sortDescriptors: [SortDescriptor] = [], where: ((Query<ResultType>) -> Query<Bool>)? = nil, keyPaths: [String]? = nil, configuration: Realm.Configuration? = nil) where ResultType: ObjectParameters
typeObserved type
sectionKeyPathThe keyPath that will produce the key for each section. For every unique value retrieved from the keyPath a section key will be generated.
sortDescriptorsA sequence of
SortDescriptors to sort by.whereObservations will be made only for passing objects. If no type safe query is given - all objects will be observed.
keyPathsOnly properties contained in the key paths array will be observed. If
nil, notifications will be delivered for any property change on the object. String key paths which do not correspond to a valid a property will throw an exception.configurationThe
Realm.Configurationused when creating the Realm. If empty the configuration is set to thedefaultConfiguration -
Initialize a
ObservedSectionedResultsstruct for a givenObjectorEmbeddedObjecttype.Note
The primary sort descriptor must be responsible for determining the section key.
Declaration
Swift
@MainActor public init(_ type: ResultType.Type, sectionKeyPath: KeyPath<ResultType, Key>, sortDescriptors: [SortDescriptor] = [], keyPaths: [String]? = nil, configuration: Realm.Configuration? = nil) where ResultType: ObjectParameters
typeObserved type
sectionKeyPathThe keyPath that will produce the key for each section. For every unique value retrieved from the keyPath a section key will be generated.
sortDescriptorsA sequence of
SortDescriptors to sort by.keyPathsOnly properties contained in the key paths array will be observed. If
nil, notifications will be delivered for any property change on the object. String key paths which do not correspond to a valid a property will throw an exception.configurationThe
Realm.Configurationused when creating the Realm. If empty the configuration is set to thedefaultConfiguration -
Initialize a
ObservedSectionedResultsstruct for a givenObjectorEmbeddedObjecttype.Note
The primary sort descriptor must be responsible for determining the section key.
Declaration
Swift
@MainActor public init(_ type: ResultType.Type, sectionBlock: @escaping ((ResultType) -> Key), sortDescriptors: [SortDescriptor], keyPaths: [String]? = nil, configuration: Realm.Configuration? = nil) where ResultType: ObjectParameters
typeObserved type
sectionBlockA callback which returns the section key for each object in the collection.
sortDescriptorsA sequence of
SortDescriptors to sort by.keyPathsOnly properties contained in the key paths array will be observed. If
nil, notifications will be delivered for any property change on the object. String key paths which do not correspond to a valid a property will throw an exception.configurationThe
Realm.Configurationused when creating the Realm. If empty the configuration is set to thedefaultConfiguration -
Declaration
Swift
nonisolated public func update()
View on GitHub
Install in Dash