Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confused when retry a Promise variable #194

Open
EkkoG opened this issue Sep 7, 2022 · 0 comments
Open

Confused when retry a Promise variable #194

EkkoG opened this issue Sep 7, 2022 · 0 comments

Comments

@EkkoG
Copy link

EkkoG commented Sep 7, 2022

With the example in the doc, https://github.com/google/promises/blob/master/g3doc/index.md#retry

retry method wraps a method that always returns a new Promise, so when the Promise of the first time method failed, retry will call the fetch method again and create a new Promise, and all work perfectly.

But if retry a Promise variable, things get wired.

let p = Promise<Int> { resolve, reject in
    print("promise")
    reject(NSError(domain: "promise", code: 1, userInfo: nil))
}

retry {
    p
}.then { _ in
    print("then")
}.catch { _ in
    print("catch")
}

code wrapped by Promise p will only run once, not twice, does this is a bug or feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant