---
title: "onStateUpdate(_:)"
framework: network
role: symbol
role_heading: Instance Method
path: "network/networkconnection/onstateupdate(_:)"
---

# onStateUpdate(_:)

Set a closure to be called when the connection’s state changes, which may be called multiple times until the connection is cancelled.

## Declaration

```swift
@discardableResult final func onStateUpdate(_ handler: @escaping @isolated(any) @Sendable (NetworkConnection<ApplicationProtocol>, NetworkChannel<ApplicationProtocol>.State) -> Void) -> Self
```

## Discussion

Discussion This closure will inherit the isolation domain of the caller.
