cookie = async getCookie(cookieId)
user = async getUser(userId)
result async user.buy(cookie)
if (result.isError()) {
error.showAlert("User has not enough money")
} else {
confirmation.showSuccess("Cookie was bought")
}
waitForMany(getCookie(cookieId), getUser(userId)
.andThen([cookie, user] -> user.buy(cookie))
.andThen(showSuccess("Cookie was bought"))
.whenError(showError("User has not enough money"))