@@ -32,7 +32,7 @@ public class IdentityMap {
32
32
public func store< T: Identifiable > (
33
33
entity: T ,
34
34
named: AliasKey < T > ? = nil ,
35
- modifiedAt: Stamp = Date ( ) . stamp ,
35
+ modifiedAt: Stamp ? = nil ,
36
36
ifPresent update: Update < T > ? = nil
37
37
) -> EntityObserver < T > {
38
38
identityQueue. sync ( flags: . barrier) {
@@ -64,7 +64,7 @@ public class IdentityMap {
64
64
public func store< T: Aggregate > (
65
65
entity: T ,
66
66
named: AliasKey < T > ? = nil ,
67
- modifiedAt: Stamp = Date ( ) . stamp ,
67
+ modifiedAt: Stamp ? = nil ,
68
68
ifPresent update: Update < T > ? = nil
69
69
) -> EntityObserver < T > {
70
70
identityQueue. sync ( flags: . barrier) {
@@ -86,7 +86,7 @@ public class IdentityMap {
86
86
}
87
87
88
88
/// Store multiple entities at once
89
- public func store< C: Collection > ( entities: C , named: AliasKey < C > ? = nil , modifiedAt: Stamp = Date ( ) . stamp )
89
+ public func store< C: Collection > ( entities: C , named: AliasKey < C > ? = nil , modifiedAt: Stamp ? = nil )
90
90
-> [ EntityObserver < C . Element > ] where C. Element: Identifiable {
91
91
identityQueue. sync ( flags: . barrier) {
92
92
let nodes = entities. map { nodeStore ( entity: $0, modifiedAt: modifiedAt) }
@@ -101,7 +101,7 @@ public class IdentityMap {
101
101
}
102
102
103
103
/// store multiple aggregates at once
104
- public func store< C: Collection > ( entities: C , named: AliasKey < C > ? = nil , modifiedAt: Stamp = Date ( ) . stamp )
104
+ public func store< C: Collection > ( entities: C , named: AliasKey < C > ? = nil , modifiedAt: Stamp ? = nil )
105
105
-> [ EntityObserver < C . Element > ] where C. Element: Aggregate {
106
106
identityQueue. sync ( flags: . barrier) {
107
107
let nodes = entities. map { nodeStore ( entity: $0, modifiedAt: modifiedAt) }
@@ -145,7 +145,7 @@ public class IdentityMap {
145
145
}
146
146
}
147
147
148
- func nodeStore< T: Identifiable > ( entity: T , modifiedAt: Stamp ) -> EntityNode < T > {
148
+ func nodeStore< T: Identifiable > ( entity: T , modifiedAt: Stamp ? ) -> EntityNode < T > {
149
149
let node = storage [ entity, new: EntityNode ( entity, modifiedAt: nil ) ]
150
150
151
151
do {
@@ -159,7 +159,7 @@ public class IdentityMap {
159
159
return node
160
160
}
161
161
162
- func nodeStore< T: Aggregate > ( entity: T , modifiedAt: Stamp ) -> EntityNode < T > {
162
+ func nodeStore< T: Aggregate > ( entity: T , modifiedAt: Stamp ? ) -> EntityNode < T > {
163
163
let node = storage [ entity, new: EntityNode ( entity, modifiedAt: nil ) ]
164
164
165
165
// disable changes while doing the entity update
@@ -197,7 +197,7 @@ extension IdentityMap {
197
197
///
198
198
/// - Returns: true if entity exists and might be updated, false otherwise. The update might **not** be applied if modifiedAt is too old
199
199
@discardableResult
200
- public func update< T: Identifiable > ( _ type: T . Type , id: T . ID , modifiedAt: Stamp = Date ( ) . stamp , update: Update < T > ) -> Bool {
200
+ public func update< T: Identifiable > ( _ type: T . Type , id: T . ID , modifiedAt: Stamp ? = nil , update: Update < T > ) -> Bool {
201
201
identityQueue. sync ( flags: . barrier) {
202
202
guard var entity = storage [ T . self, id: id] ? . ref. value else {
203
203
return false
@@ -218,7 +218,7 @@ extension IdentityMap {
218
218
///
219
219
/// - Returns: true if entity exists and might be updated, false otherwise. The update might **not** be applied if modifiedAt is too old
220
220
@discardableResult
221
- public func update< T: Aggregate > ( _ type: T . Type , id: T . ID , modifiedAt: Stamp = Date ( ) . stamp , _ update: Update < T > ) -> Bool {
221
+ public func update< T: Aggregate > ( _ type: T . Type , id: T . ID , modifiedAt: Stamp ? = nil , _ update: Update < T > ) -> Bool {
222
222
identityQueue. sync ( flags: . barrier) {
223
223
guard var entity = storage [ T . self, id: id] ? . ref. value else {
224
224
return false
@@ -237,7 +237,7 @@ extension IdentityMap {
237
237
/// the change was applied
238
238
/// - Returns: true if entity exists and might be updated, false otherwise. The update might **not** be applied if modifiedAt is too old
239
239
@discardableResult
240
- public func update< T: Identifiable > ( named: AliasKey < T > , modifiedAt: Stamp = Date ( ) . stamp , update: Update < T > ) -> Bool {
240
+ public func update< T: Identifiable > ( named: AliasKey < T > , modifiedAt: Stamp ? = nil , update: Update < T > ) -> Bool {
241
241
identityQueue. sync ( flags: . barrier) {
242
242
guard let entity = refAliases [ named] . value else {
243
243
return false
@@ -259,7 +259,7 @@ extension IdentityMap {
259
259
/// the change was applied
260
260
/// - Returns: true if entity exists and might be updated, false otherwise. The update might **not** be applied if modifiedAt is too old
261
261
@discardableResult
262
- public func update< T: Aggregate > ( named: AliasKey < T > , modifiedAt: Stamp = Date ( ) . stamp , update: Update < T > ) -> Bool {
262
+ public func update< T: Aggregate > ( named: AliasKey < T > , modifiedAt: Stamp ? = nil , update: Update < T > ) -> Bool {
263
263
identityQueue. sync ( flags: . barrier) {
264
264
guard let entity = refAliases [ named] . value else {
265
265
return false
@@ -281,7 +281,8 @@ extension IdentityMap {
281
281
/// the change was applied
282
282
/// - Returns: true if entity exists and might be updated, false otherwise. The update might **not** be applied if modifiedAt is too old
283
283
@discardableResult
284
- public func update< C: Collection > ( named: AliasKey < C > , modifiedAt: Stamp = Date ( ) . stamp, update: Update < [ C . Element ] > ) -> Bool where C. Element: Identifiable {
284
+ public func update< C: Collection > ( named: AliasKey < C > , modifiedAt: Stamp ? = nil , update: Update < [ C . Element ] > )
285
+ -> Bool where C. Element: Identifiable {
285
286
identityQueue. sync ( flags: . barrier) {
286
287
guard let entities = refAliases [ named] . value else {
287
288
return false
@@ -304,7 +305,8 @@ extension IdentityMap {
304
305
/// the change was applied
305
306
/// - Returns: true if entity exists and might be updated, false otherwise. The update might **not** be applied if modifiedAt is too old
306
307
@discardableResult
307
- public func update< C: Collection > ( named: AliasKey < C > , modifiedAt: Stamp = Date ( ) . stamp, update: Update < [ C . Element ] > ) -> Bool where C. Element: Aggregate {
308
+ public func update< C: Collection > ( named: AliasKey < C > , modifiedAt: Stamp ? = nil , update: Update < [ C . Element ] > )
309
+ -> Bool where C. Element: Aggregate {
308
310
identityQueue. sync ( flags: . barrier) {
309
311
guard let entities = refAliases [ named] . value else {
310
312
return false
@@ -343,8 +345,8 @@ extension IdentityMap {
343
345
refAliases. removeAll ( )
344
346
}
345
347
346
- /// Removes all alias AND all objects stored weakly. You should not need this method and rather use `removeAlias`. But this can be useful
347
- /// if you fear retain cycles
348
+ /// Removes all alias AND all objects stored weakly. You should not need this method and rather use `removeAlias`.
349
+ /// But this can be useful if you fear retain cycles
348
350
public func removeAll( ) {
349
351
refAliases. removeAll ( )
350
352
storage. removeAll ( )
0 commit comments