diff --git a/LeStorage/BaseCollection.swift b/LeStorage/BaseCollection.swift index 5567405..f2aef21 100644 --- a/LeStorage/BaseCollection.swift +++ b/LeStorage/BaseCollection.swift @@ -65,6 +65,11 @@ public class BaseCollection: SomeCollection, CollectionHolder { /// Sets a max number of items inside the collection fileprivate(set) var limit: Int? = nil + init(store: Store) async { + self.store = store + await self.loadFromFile() + } + init(store: Store, indexed: Bool = false, inMemory: Bool = false, limit: Int? = nil, synchronousLoading: Bool = false) { if indexed { self._indexes = [:] diff --git a/LeStorage/Store.swift b/LeStorage/Store.swift index 088474d..ddaba8a 100644 --- a/LeStorage/Store.swift +++ b/LeStorage/Store.swift @@ -115,6 +115,13 @@ final public class Store { return collection } + func synchronizedCollectionWithFileLoading() async -> SyncedCollection { + let collection = await SyncedCollection(store: self) + self._collections[T.resourceName()] = collection + self.storeCenter.loadApiCallCollection(type: T.self) + return collection + } + /// Registers a singleton object /// - Parameters: /// - synchronized: indicates if the data is synchronized with the server