<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 26.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/onDragSessionUpdated(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE20onDragSessionUpdatedyQryAA0eF0VcF"
  },
  "title" : "onDragSessionUpdated(_:)"
}
-->

# onDragSessionUpdated(_:)

Specifies an action to perform on each update of an ongoing dragging operation
activated by `draggable(_:)` or anther drag modifiers.

```
nonisolated func onDragSessionUpdated(_ onUpdate: @escaping (DragSession) -> Void) -> some View
```

## Discussion

Below is an example of a view that displays a book and supports
dragging to copy, move, and delete. If the session ends
with moving or deleting the item, in the `onUpdate` closure,
the view lets the model layer know that the book should be deleted
from the source.

```
struct DraggableBookView: View {
    var id: UUID

    var body: some View {
        BookView()
            .draggable(Book(id: id))
            .dragConfiguration(
                DragConfiguration(
                    operationsWithinApp: .init(allowMove: true, allowDelete: true),
                    operationsOutsideApp: .init(allowMove: true, allowDelete: true)
                ))
            .onDragSessionUpdated { session in
                switch session.phase {
                case .ended(at: _, with: let operation):
                    if operation == .move || operation == .delete {
                        if let id = session.draggedItemIDs(type: UUID.self).first {
                            removeBook(id: id)
                        }
                    }
                default:
                    break
                }
            }
    }
}

func removeBook(id: UUID) { }
```

The `onUpdate` closure is called when the closest drag session
in the child view hierarchy becomes active.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)