mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
SwiftUI : how to use ListPublisher in Views #347
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.