What is Nostr?
mattcomi /
npub1z75…dt84
2025-02-14 01:55:08

mattcomi on Nostr: #swiftui tip: If you want to fire an action when "foo” or "bar” changes, you can ...

#swiftui tip: If you want to fire an action when "foo” or "bar” changes, you can do this:

.onChange(of: foo) {
action()
}
.onChange(of: bar) {
action()
}

But you can't do this:

.onChange(of: foo || bar) {}

However, if foo and bar are the same type, you *can* do this:

.onChange(of: [foo, bar]) {}

This works because Array conforms to Equatable when its Element does.
Author Public Key
npub1z75y6l7v3wtp47dgpj0cx7f87sqgtvyvgq5yjx6cct3xqhvmth2q4fdt84