During development we saw that we can have a parent class that is annotated with the @observable macro, we can subclass it and that would require also the macro if there are items we need to observe there too! is this the intended behavior or are we doing something wrong?
@observable open class Service {
var val: Int
}
@observable final class FinalService: Service {
var str: String
}
1- Is subclassing an @Observable macroed class okay? from my basic understanding how its compiled, the compiler is smart enough to know its alright to have the macro on both the parent and the child.
2- Would it be better to simply append the @Observable on the child only?
This is from the swift evolution:
Subclasses
Developers can createObservablesubclasses of either observable or non-observable types. Only the properties of a type that implements theObservabletracking requirements will be observed. That is, when working with an observable subclass of a non-observable type, the superclass's stored properties will not be tracked under observation.