Search code examples
swiftpromisekit

PromiseKit in Linux swift project works not as expected


If you execute in Linux swift project something like:

import PromiseKit

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

getResult($0) will never be executed. Why?


Solution

  • In Linux swift project you need to use:

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

    PS. Works on Ubuntu 16.04, Swift 4.2