The lazy deserialization is evident if you print a decoded path.
For example, given this path:
var path = NavigationPath()
path.append("Hello")
path.append(123)
print(path)
Here is the output (reformatted for legibility):
NavigationPath(
_items: blahblahblah.Representation.eager(
[
SwiftUI.(unknown context at $11567e6b8).CodableItemBox<Swift.String>,
SwiftUI.(unknown context at $11567e6b8).CodableItemBox<Swift.Int>
]
),
subsequentItems: [],
iterationIndex: 0
)
And if we create a new path from that path's codable
:
let path2 = NavigationPath(path.codable!)
print(path2)
we get this output:
NavigationPath(
_items: blahblahblah.Representation.lazy(
SwiftUI.NavigationPath.CodableRepresentation(
resolvedItems: [
SwiftUI.(unknown context at $11567e6b8).CodableItemBox<Swift.String>,
SwiftUI.(unknown context at $11567e6b8).CodableItemBox<Swift.Int>
],
remainingItemsReversed: [],
subsequentItems: []
)
),
subsequentItems: [],
iterationIndex: 0
)
Furthermore, the old and new paths are not equal:
print(path == path, path2 == path2, path == path2)
// true true false
If we go all the way through the JSON representation:
let path3 = NavigationPath(try! JSONDecoder().decode(NavigationPath.CodableRepresentation.self, from: try! JSONEncoder().encode(path.codable!)))
print(path3)
then we get a different lazy
representation in which we can see that it stores each path element's type and JSON representation, with no individual path element decoded:
NavigationPath(
_items: blahblahblah.Representation.lazy(
SwiftUI.NavigationPath.CodableRepresentation(
resolvedItems: [],
remainingItemsReversed: [
(tag: "Swift.Int", item: "123"),
(tag: "Swift.String", item: "\"Hello\"")
],
subsequentItems: []
)
),
subsequentItems: [],
iterationIndex: 0
)