google / google/promises

Confused when retry a Promise variable

Open
#194 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Objective-C
Stars
3.8k
Forks
316
PR merge metrics
No merged PRs in 30d

Description

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.

```swift
let p = Promise { 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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.