---
title: "next(isolation:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/asyncstream/iterator/next(isolation:)"
---

# next(isolation:)

The next value from the asynchronous stream.

## Declaration

```swift
mutating func next(isolation actor: isolated (any Actor)?) async -> Element?
```

## Discussion

Discussion When next() returns nil, this signifies the end of the AsyncStream. It is a programmer error to invoke next() from a concurrent context that contends with another such call, which results in a call to fatalError(). If you cancel the task this iterator is running in while next() is awaiting a value, the AsyncStream terminates. In this case, next() might return nil immediately, or return nil on subsequent calls.
