|
|
|
|
@ -154,11 +154,15 @@ public class StoredCollection<T: Storable>: RandomAccessCollection, SomeCollecti |
|
|
|
|
if self.asynchronousIO { |
|
|
|
|
DispatchQueue.main.async { |
|
|
|
|
self._setItems(decoded) |
|
|
|
|
self._setAsLoaded() |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
self._setItems(decoded) |
|
|
|
|
self._setAsLoaded() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
self._setAsLoaded() |
|
|
|
|
} |
|
|
|
|
// else if self.synchronized { |
|
|
|
|
// Task { |
|
|
|
|
// do { |
|
|
|
|
@ -171,10 +175,14 @@ public class StoredCollection<T: Storable>: RandomAccessCollection, SomeCollecti |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _setAsLoaded() { |
|
|
|
|
self.hasLoadedLocally = true |
|
|
|
|
NotificationCenter.default.post(name: NSNotification.Name.CollectionDidLoad, object: self) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _setItems(_ items: [T]) { |
|
|
|
|
self.items = items |
|
|
|
|
self._updateIndexIfNecessary() |
|
|
|
|
NotificationCenter.default.post(name: NSNotification.Name.CollectionDidLoad, object: self) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Updates the whole index with the items array |
|
|
|
|
|