Contents

withMutation(of:keyPath:_:)

Identifies mutations to the transactions registered for observers.

Declaration

func withMutation<Subject, Member, T>(of subject: Subject, keyPath: KeyPath<Subject, Member>, _ mutation: () throws -> T) rethrows -> T where Subject : Observable

Parameters

  • subject:

    An instance of an observable type.

  • keyPath:

    The key path of an observed property.

Discussion

This method calls willSet(_:keyPath:) before the mutation. Then it calls didSet(_:keyPath:) after the mutation.

See Also

Identifying transactional access