Skip to content

Conversation

@moaible
Copy link
Contributor

@moaible moaible commented Mar 17, 2018

Hey guys, I want to add feature that retryWhen operator with retry operator's conditional promise to determine whether retry is possible even if not reached maximum retry count.

Promise<Int> { (resolve, reject, _) in
    currentAttempt += 1
    if currentAttempt < successOnAttempt {
        print("attempt is \(currentAttempt)... reject")
        reject(TestErrors.anotherError)
    } else {
        print("attempt is \(currentAttempt)... resolve")
        resolve(5)
    }
}.retryWhen(retryAttempts) { (remainAttempts, error) -> Promise<Bool> in
    if remainAttempts > retryableRemainAttempt {
        print("retry remainAttempts is \(remainAttempts)... true")
        return Promise<Bool>(resolved: true).defer(5) // I want here promise chain.
    } else {
        print("retry remainAttempts is \(remainAttempts)... false")
        return Promise<Bool>(resolved: false)
    }
}

@moaible moaible changed the title Add 'RetryWhen' operator Add 'retryWhen' operator Mar 17, 2018
@malcommac malcommac self-requested a review March 28, 2019 07:43
@malcommac malcommac self-assigned this Mar 28, 2019
@malcommac malcommac added this to the 2.0.0 milestone Mar 28, 2019
@malcommac malcommac changed the base branch from master to develop March 28, 2019 07:44
@malcommac malcommac merged commit e9f6d9d into malcommac:develop Mar 28, 2019
@malcommac
Copy link
Owner

Nice addition, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants