Closed fedesog closed 10 years ago
It is technically doable, but it doesn't look like a good idea as it'll encourage people to flag as changed more than has actually changed, leading to perhaps significant unnecessary churn.
The side effect you see is simply because &value and &value.FirstField will necessary point to the same address.
What about using a variadic parameter instead? Users would have to specify each modified field with the only difference that qml.Changed could be called just once instead of once per field. The function signature would be similar and backward compatible: func Changed(value interface{}, fieldAddrs ...interface{}) In any case the function should be probably be fixed to panic if erroneously called with qml.Changed(value, &value).
Is it possible to expand qml.Changed to notify QML that all fields of a value has been changed. So far calling qml.Changed passing the address of the value is equivalent to notify that the first field of the struct has been changed (unplanned behaviour?).
Example: