目录
目录README.md

AsyncK

Carthage compatible Swift Package Manager

AsyncK provides Async, await, beginAsync and suspendAsync which are compatible with ones in this proposal.

The following code written with async/await

func foo() async -> Int {
    return suspendAsync { continuation in
        // ...
    }
}

func bar(_ x: Int) async -> Int {
    // ...
}

beginAsync {
    let a = await foo()
    let b = await bar(a)
    print(b)
}

can be rewritten as follows:

func foo() -> Async<Int> {
    return suspendAsync { continuation in
        // ...
    }
}

func bar(_ x: Int) -> Async<Int> {
    // ...
}

beginAsync {
    foo().await { a in
        bar(a).await { b -> Void in
            print(b)
        }
    }
}

It is also possible to flatten the nest inside the beginAsync‘s trailing closure.

foo().await { a in
    bar(a)
}.await { b -> Void in
    print(b)
}

License

MIT

邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号