[Second review] SE-0395: Observability

View should not be responsible to post VMs events. That’s violation of encapsulation and will lead to a huge mess if VM is shared between several views.

Better approach would be to override withMutation() in VM:

    internal func withMutation<Member, T>(
        keyPath: KeyPath<Model, Member>,
        _ mutation: () throws -> T
    ) rethrows -> T {
        self.objectWillChange.send()
        try _$observationRegistrar.withMutation(of: self, keyPath: keyPath, mutation)
    }
2 Likes