Javascript promises in Swift