How can I change this, when SegmentsListSectionView excepts segments to be of type [Segment]?
I found that I can avoid errors with [ListSnapshot<Segment>.Element] but this seems like I am just diving into trouble.
And should I even go this route? The docs say ListPublisher does not track detailed inserts, deletes, and moves - so deleting an item from my list won't work with ListPublisher - but ListMonitor doesn't support SwiftUI.
Would appreciate any help - even if the answer is that it won't work with SwiftUI and I need to go back to pure CoreData (which I have loads of trouble as well - so my hope has been with CoreStore).
Thank you.
Originally created by @distantnative on GitHub (Nov 9, 2020).
Hi there,
I'm quite excited about finding CoreStore but I am struggling a bit to put it in SwiftUI - which might be just my poor skills.
So I have an object
```swift
class Segment: CoreStoreObject {
@Field.Stored("purpose")
var purpose: String = ""
static public func upcoming() -> ListPublisher<Segment> {
DataStore.stack.publishList(
From<Segment>()
.where(\.$from >= Date())
.orderBy(.ascending(\.$from))
)
}
}
```
and then my view where I want to list them
```swift
struct SegmentsListView: View {
@ObservedObject var upcoming: ListPublisher<Segment> = Segment.upcoming()
var body: some View {
List {
SegmentsListSectionView(
title: "Upcoming",
segments: self.upcoming
)
}
}
}
```
How can I change this, when `SegmentsListSectionView` excepts `segments` to be of type `[Segment]`?
I found that I can avoid errors with `[ListSnapshot<Segment>.Element]` but this seems like I am just diving into trouble.
And should I even go this route? The docs say `ListPublisher does not track detailed inserts, deletes, and moves` - so deleting an item from my list won't work with `ListPublisher` - but `ListMonitor` doesn't support SwiftUI.
Would appreciate any help - even if the answer is that it won't work with SwiftUI and I need to go back to pure CoreData (which I have loads of trouble as well - so my hope has been with CoreStore).
Thank you.
adam
added the question label 2025-12-29 18:25:55 +01:00
@distantnative ListPublisher will work for your needs here. I admit the documentation may be misleading here:
ListPublisher does not track detailed inserts, deletes, and moves
It just means that you'll get the updated list of objects, but you won't know which objects were inserted, deleted, edited, or moved.
Since you are using SwiftUI, I assume that your Views just iterate on the ListSnapshot whenever the ListPublisher is updated, and if that's the case, it should be suitable for your use case.
@JohnEstropia commented on GitHub (Nov 11, 2020):
@distantnative `ListPublisher` will work for your needs here. I admit the documentation may be misleading here:
> `ListPublisher` does not track detailed inserts, deletes, and moves
It just means that you'll get the updated list of objects, but you won't know which objects were inserted, deleted, edited, or moved.
Since you are using SwiftUI, I assume that your `View`s just iterate on the `ListSnapshot` whenever the `ListPublisher` is updated, and if that's the case, it should be suitable for your use case.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @distantnative on GitHub (Nov 9, 2020).
Hi there,
I'm quite excited about finding CoreStore but I am struggling a bit to put it in SwiftUI - which might be just my poor skills.
So I have an object
and then my view where I want to list them
How can I change this, when
SegmentsListSectionViewexceptssegmentsto be of type[Segment]?I found that I can avoid errors with
[ListSnapshot<Segment>.Element]but this seems like I am just diving into trouble.And should I even go this route? The docs say
ListPublisher does not track detailed inserts, deletes, and moves- so deleting an item from my list won't work withListPublisher- butListMonitordoesn't support SwiftUI.Would appreciate any help - even if the answer is that it won't work with SwiftUI and I need to go back to pure CoreData (which I have loads of trouble as well - so my hope has been with CoreStore).
Thank you.
@JohnEstropia commented on GitHub (Nov 11, 2020):
@distantnative
ListPublisherwill work for your needs here. I admit the documentation may be misleading here:It just means that you'll get the updated list of objects, but you won't know which objects were inserted, deleted, edited, or moved.
Since you are using SwiftUI, I assume that your
Views just iterate on theListSnapshotwhenever theListPublisheris updated, and if that's the case, it should be suitable for your use case.