Skip to content

Commit

Permalink
Implement the Perceptible macro conformance manually (#256)
Browse files Browse the repository at this point in the history
* Manually implement Perceptible conformance.

* wip

* fix
  • Loading branch information
mbrandonw authored Dec 19, 2024
1 parent 29ccee2 commit e289117
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Sources/SwiftNavigation/UIBinding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,27 @@ private final class _UIBindingWeakRoot<Root: AnyObject, Value>: _UIBinding, @unc
}
}

@Perceptible
private final class _UIBindingWrapper<Value> {
var value: Value
private final class _UIBindingWrapper<Value>: Perceptible, Observable {
var _value: Value
var value: Value {
get {
_$perceptionRegistrar.access(self, keyPath: \.value)
return _value
}
set {
_$perceptionRegistrar.withMutation(of: self, keyPath: \.value) {
_value = newValue
}
}
_modify {
_$perceptionRegistrar.willSet(self, keyPath: \.value)
defer { _$perceptionRegistrar.didSet(self, keyPath: \.value) }
yield &_value
}
}
let _$perceptionRegistrar = PerceptionRegistrar()
init(_ value: Value) {
self.value = value
self._value = value
}
}

Expand Down

0 comments on commit e289117

Please sign in to comment.