google / promises

Promises is a modern framework that provides a synchronization construct for Swift and Objective-C.
Apache License 2.0
3.79k stars 291 forks source link

Question. Is it possible to change the delay time between retrys? #184

Open brandon2727 opened 2 years ago

brandon2727 commented 2 years ago

Not an issue. Just a question. Is it possible to change the delay time between promise retrys? I would like to implement the Exponential Backoff and Retry Pattern with different time intervals. This is what I have so far

public static func genericRequestWithRetry(with api: EndPoint) -> Promise {

    let customQueue = DispatchQueue(label: "GenericRequestQueue", qos: .userInitiated)

    return retry(on: customQueue, attempts: 3, delay: 2, condition: { remainingAttempts, error in

     // here I would like to change the delay value and then retry

    }
    ) {
        genericRequest(with: api)
    }
}