# Are there any good examples of an AsyncSequence powered by a ChannelHandler?

**URL:** <https://forums.swift.org/t/are-there-any-good-examples-of-an-asyncsequence-powered-by-a-channelhandler/47870>\
**Category:** SwiftNIO\
**Created:** [May 3, 2021, 6:53pm UTC](https://forums.swift.org/t/are-there-any-good-examples-of-an-asyncsequence-powered-by-a-channelhandler/47870 "2021-05-03T18:53:42Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![George](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/george/32/37757_2.png) [@George](https://forums.swift.org/u/George)\
**Post date:** [May 6, 2021, 11:30pm UTC](https://forums.swift.org/t/are-there-any-good-examples-of-an-asyncsequence-powered-by-a-channelhandler/47870/10 "2021-05-06T23:30:44Z")

</div>

The PostgresNIO example wasn't exactly what I was looking for, so I wrote my own.

It includes a handler with an async `next` method (this could theoretically confirm to `AsyncIterator` directly, but that feels a bit off to me).

> <https://github.com/GeorgeLyon/Shwift/blob/5cd82238b9736ec3b9b41bd673ee51d98983f969/Sources/Shwift/Shell.swift#L112-L212>

I then have a simple `AsyncIterator` which repeatedly calls `next` on a handler:

> <https://github.com/GeorgeLyon/Shwift/blob/5cd82238b9736ec3b9b41bd673ee51d98983f969/Sources/Shwift/Shell.swift#L66-L89>

@lukasa If this is something that would be interesting to contribute to NIO (and doesn't have any obvious pitfalls I'm missing). I'm not super familiar with the NIO project structure so if someone could point me in the right direction (for instance, where would be a good place for something like this to live), I'd be happy to work up a PR.

---

_[View the full topic](https://forums.swift.org/t/are-there-any-good-examples-of-an-asyncsequence-powered-by-a-channelhandler/47870)._
