Skip to content
Stream which mimics the behaviour of channels
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Swift Zewo Platform License Slack Travis

ChannelStream is a stream which mimics the behaviour of CSP channels.


You can send inside the closure and receive outside the closure.

let channelStream = ChannelStream { stream in
    try stream.send("hello")

let hello = try channelStream.receive()

Or you can send outside the closure and receive inside the closure.

let channelStream = ChannelStream { stream in
    let hello = try stream.receive()

try channelStream.send("hello")

Or you can do both at the same time.

let channelStream = ChannelStream { stream in
    let hello = try stream.receive()
    try stream.send("goodbye")

try channelStream.send("hello")
let goodbye = try channelStream.receive()

A good usage example of ChannelStream is generating an HTTP response body dynamically.

import HTTPServer
import ChannelStream

try Server { _ in
    let stream = ChannelStream { stream in
        for i in 0 ..< 100 {
            try stream.send("\(i)")
    return Response(body: stream)


import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "", majorVersion: 0, minor: 4)


If you need any help you can join our Slack and go to the #help channel. Or you can create a Github issue in our main repository. When stating your issue be sure to add enough details, specify what module is causing the problem and reproduction steps.



The entire Zewo code base is licensed under MIT. By contributing to Zewo you are contributing to an open and engaged community of brilliant Swift programmers. Join us on Slack to get to know us!


This project is released under the MIT license. See LICENSE for details.

You can’t perform that action at this time.