Skip to content

Commit 6382917

Browse files
authored
Keep a ref to store in AnyStore classes (#22)
1 parent b835f7e commit 6382917

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Sources/Blueprints/AnyMultiObjectStore.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public final class AnyMultiObjectStore<
77
public init<Store: MultiObjectStore>(
88
_ store: Store
99
) where Store.Object == Object {
10+
_store = store
1011
_save = { try store.save($0) }
1112
_saveOptional = { try store.save($0) }
1213
_saveObjects = { try store.save($0) }
@@ -20,6 +21,7 @@ public final class AnyMultiObjectStore<
2021
_removeAll = { try store.removeAll() }
2122
}
2223

24+
private let _store: any MultiObjectStore
2325
private let _save: (Object) throws -> Void
2426
private let _saveOptional: (Object?) throws -> Void
2527
private let _saveObjects: ([Object]) throws -> Void

Sources/Blueprints/AnySingleObjectStore.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ public final class AnySingleObjectStore<Object: Codable>: SingleObjectStore {
55
public init<Store: SingleObjectStore>(
66
_ store: Store
77
) where Store.Object == Object {
8+
_store = store
89
_save = { try store.save($0) }
910
_saveOptional = { try store.save($0) }
1011
_object = { store.object() }
1112
_remove = { try store.remove() }
1213
}
1314

15+
private let _store: any SingleObjectStore
1416
private let _save: (Object) throws -> Void
1517
private let _saveOptional: (Object?) throws -> Void
1618
private let _object: () -> Object?

0 commit comments

Comments
 (0)