【问题标题】:PromiseKit in Linux swift project works not as expectedLinux swift 项目中的 PromiseKit 无法按预期工作
【发布时间】:2019-04-16 10:19:10
【问题描述】:

如果你在 Linux swift 项目中执行类似:

import PromiseKit

func runAsyncAction() {
    firstly {
        executeSomePromiseFunc()
    }.done {
        getResult($0)
    }
}

getResult($0) 永远不会被执行。为什么?

【问题讨论】:

    标签: swift promisekit


    【解决方案1】:

    在Linux swift项目中你需要使用:

    import PromiseKit
    import Dispatch
    
    func runAsyncAction() {
        firstly {
            executeSomePromiseFunc()
        }.done(on:DispatchQueue.global()) {
            getResult($0)
        }.ensure(on:DispatchQueue.global()) {
    
        }.catch(on:DispatchQueue.global()) {
    
        }
    }
    

    PS。适用于 Ubuntu 16.04、Swift 4.2

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-17
      • 1970-01-01
      • 1970-01-01
      • 2012-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多