Skip to content

Commit

Permalink
Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii committed Jan 23, 2025
1 parent 6b10d20 commit 6cba434
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Sources/Verge/SwiftUI/StoreReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ public enum StoreReaderComponents<StateType: Equatable> {
// Proxy
@MainActor
@dynamicMemberLookup
public struct StateProxy {
public struct StateProxy: ~Copyable {

typealias Detectors = [PartialKeyPath<StateType> : (Changes<StateType>) -> Bool]

private let wrapped: StateType
private let wrapped: ReadonlyBox<StateType>

/// wrapped value itself
public var primitive: StateType {
Expand All @@ -102,7 +102,10 @@ public enum StoreReaderComponents<StateType: Equatable> {
private(set) var detectors: Detectors = [:]
private weak var source: (any StoreDriverType<StateType>)?

init(wrapped: StateType, source: (any StoreDriverType<StateType>)?) {
init(
wrapped: ReadonlyBox<StateType>,
source: (any StoreDriverType<StateType>)?
) {
self.wrapped = wrapped
self.source = source
}
Expand Down Expand Up @@ -140,7 +143,7 @@ public enum StoreReaderComponents<StateType: Equatable> {
detectors[keyPath] = maybeChanged
}

return wrapped[keyPath: keyPath]
return wrapped[keyPath: \.value][keyPath: keyPath]
}
}

Expand All @@ -161,7 +164,7 @@ public enum StoreReaderComponents<StateType: Equatable> {
detectors[keyPath] = maybeChanged
}

return wrapped[keyPath: keyPath]
return wrapped[keyPath: \.value][keyPath: keyPath]
}

}
Expand Down Expand Up @@ -279,7 +282,7 @@ public enum StoreReaderComponents<StateType: Equatable> {
-> Content
{

var tracker = StateProxy(wrapped: currentValue.primitive, source: source)
var tracker = StateProxy(wrapped: currentValue.primitiveBox, source: source)
let content = make(&tracker)

detectors = tracker.detectors
Expand Down

0 comments on commit 6cba434

Please sign in to comment.