---
title: cancel()
framework: combine
role: symbol
role_heading: Instance Method
path: combine/cancellable/cancel()
---

# cancel()

Cancel the activity.

## Declaration

```swift
func cancel()
```

## Mentioned in

Receiving and Handling Events with Combine Controlling Publishing with Connectable Publishers

## Discussion

Discussion When implementing Cancellable in support of a custom publisher, implement cancel() to request that your publisher stop calling its downstream subscribers. Combine doesn’t require that the publisher stop immediately, but the cancel() call should take effect quickly. Canceling should also eliminate any strong references it currently holds. After you receive one call to cancel(), subsequent calls shouldn’t do anything. Additionally, your implementation must be thread-safe, and it shouldn’t block the caller. tip: Keep in mind that your cancel() may execute concurrently with another call to cancel() — including the scenario where an AnyCancellable is deallocating — or to request(_:).
