---
title: "withMutation(of:keyPath:_:)"
framework: observation
role: symbol
role_heading: Instance Method
path: "observation/observationregistrar/withmutation(of:keypath:_:)"
---

# withMutation(of:keyPath:_:)

Identifies mutations to the transactions registered for observers.

## Declaration

```swift
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

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

## See Also

### Identifying transactional access

- [access(_:keyPath:)](observation/observationregistrar/access(_:keypath:).md)
