I have an observable object called MyObject that has a published property called property. property is String.
I have this
.onChange(of:myObject.property, perform: { value in
}
the problem is that value contains the old value of property, when this is triggered.
Apple docs say you can capture the new and old value of properties by doing this:
@State private var playState: PlayState = .paused
.onChange(of: playState) { [playState] newState in
print(playState, self.playState, newState)
}
I don't see how I should type the command for my case.
I have tried
.onChange(of:myObject.property, perform: { [myObject.property] newValue in
but Xcode says
Expected 'weak', 'unowned', or no specifier in capture list
Any ideas?