Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions Sources/StateStruct/PropertyPath.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

public struct PropertyPath: Equatable {
@DebugDescription
public struct PropertyPath: Equatable, CustomDebugStringConvertible {

public struct Component: Equatable {

Expand All @@ -11,7 +12,13 @@ public struct PropertyPath: Equatable {

}

public var components: [Component] = []
public var components: [Component] = [] {
didSet {
#if DEBUG
_joined = components.map { $0.value }.joined(separator: ".")
#endif
}
}

public init() {

Expand All @@ -26,5 +33,19 @@ public struct PropertyPath: Equatable {
self.components.append(component)
return self
}

#if DEBUG
private var _joined: String = ""
#endif

#if DEBUG
public var debugDescription: String {
"\(_joined) \(components.count)"
}
#else
public var debugDescription: String {
"Components : \(components.count)"
}
#endif

}
9 changes: 7 additions & 2 deletions Sources/StateStruct/TrackingRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ public enum TrackingRuntime {
trackingContext: borrowing _TrackingContext
) -> Value {

trackingContext.trackingResultRef?.accessorRead(path: trackingContext.path?.pushed(component))

if
let ref = trackingContext.trackingResultRef,
let path = trackingContext.path
{
ref.accessorRead(path: path.pushed(component))
}

if var value = value as? TrackingObject, let ref = trackingContext.trackingResultRef {

if value._tracking_context.trackingResultRef !== ref {
Expand Down