@alpennec @squeakytoy wait, what does it mean equatable properties don't trigger updates? 🤔 #Swift #SwiftUI
Post
@alpennec @squeakytoy wait, what does it mean equatable properties don't trigger updates? 🤔 #Swift #SwiftUI
@konstantin @alpennec In some situations `Observable` is not able to perform this check for you. `Observable` generates code that dispatches statically at compile time to test for equality. If your `Observable` type *does not know* at compile time if these types are Equatable then it will not perform a dynamic runtime check for you. This can be one option to "opt out" of the equality checking.
https://forums.swift.org/t/understanding-when-swiftui-re-renders-an-observable/77876/
@konstantin @alpennec The other option I believe to opt out of equality checking is to provide *your own* `shouldNotifyObservers` method that returns `true`. I believe the macro will respect your method and will choose not to generate new ones.
@konstantin @alpennec I understand the motivation for these changes… but I'm also torn. Because now we are performing a linear time operation to set collection properties. This is not always the right choice… but I can understand why it might be the right choice in many places. But I do think engineers should learn exactly what is happening and exactly how to opt out of this behavior if that would improve performance.
 @konstantin  @alpennec @squeakytoy@bird.makeup I think that values you set but didn’t actually change won’t trigger updates. 
Like guard newValue != oldValue else return in the setter
@helge @konstantin yep, I updated my post to be more explicit. Of course it triggers updates for Equatable properties, but only when the old and new value differ. Otherwise nothing is published, it’s ignored.
A space for Bonfire maintainers and contributors to communicate