-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shorthand property for entity identifier in Derived (#501)
- Loading branch information
Showing
3 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
16 changes: 15 additions & 1 deletion
16
Sources/VergeNormalizationDerived/EntityType+Typealias.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
|
||
extension EntityType { | ||
|
||
public typealias Derived = Verge.Derived<EntityWrapper<Self>> | ||
public typealias NonNullDerived = Verge.Derived<NonNullEntityWrapper<Self>> | ||
|
||
} | ||
|
||
extension Derived where Value: NonNullEntityWrapperType { | ||
|
||
public var entityID: Value.Entity.TypedID { | ||
self.state.id | ||
} | ||
} | ||
|
||
extension Derived where Value: EntityWrapperType { | ||
|
||
public var entityID: Value.Entity.TypedID? { | ||
self.state.id | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 8 additions & 2 deletions
10
Sources/VergeNormalizationDerived/NonNullEntityWrapper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters