Convert CollectionListModel to ObservableObject

This commit is contained in:
Angelo Stavrow 2020-08-25 11:27:15 -04:00
parent f118d58d5c
commit eebbf1a909
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

View File

@ -1,18 +1,13 @@
import SwiftUI
struct CollectionListModel {
class CollectionListModel: ObservableObject {
private(set) var userCollections: [PostCollection] = []
private(set) var collectionsList: [PostCollection]
init() {
collectionsList = [ allPostsCollection, draftsCollection ]
#if DEBUG
userCollections = [ userCollection1, userCollection2, userCollection3 ]
#endif
@Published private(set) var collectionsList: [PostCollection] = [ allPostsCollection, draftsCollection ]
init(with userCollections: [PostCollection]) {
for userCollection in userCollections {
collectionsList.append(userCollection)
self.userCollections.append(userCollection)
}
collectionsList.append(contentsOf: self.userCollections)
}
}