Promise implementation in Swift