RxSwiftAutoRetry

master

SwingDev/RxSwiftAutoRetry

RxSwiftAutoRetry

CI Status Version Carthage compatible License Platform

RxSwiftAutoRetry is an extension to RxSwift - a well-known Reactive Swift framework. It allows user to retry observable after exponential time. It also provides simple way to randomize time of delay.

Example

To run the example project, clone the repo, and run pod install from the root project directory first.

Tests

To run tests, run carthage update from the root project directory first.

Requirements

  • iOS 8.0+
  • macOS 10.9+

Installation

CocoaPods

CocoaPods is a dependency manager, which simplifies adding 3rd-party libraries. To install it, add the following line to your Podfile:

pod 'RxSwiftAutoRetry'

Then, you need to run below comand to install framework into your project:

pod install

Carthage

Carthage is decentralized dependency manager which allows you to keep your dependencies in compiled format.

  1. To install it, add following line to your Cartfile:
github 'SwingDev/RxSwiftAutoRetry'
  1. Next, run carthage update
  2. On your application targets’ Build Phases tab, in the Link Binary With Libraries section, drag and drop RxSwift.framework and RxSwiftAutoRetry.framework from the Carthage/Build folder on disk.
  3. On your application targets’ Build Phases settings tab, click the + icon and choose New Run Script Phase. Create a Run Script in which you specify your shell (ex: /bin/sh), add the following contents to the script area below the shell:
/usr/local/bin/carthage copy-frameworks
  1. Add the paths to the frameworks you want to use under “Input Files". For example:
$(SRCROOT)/Carthage/Build/<platform>/RxSwift.framework
$(SRCROOT)/Carthage/Build/<platform>/RxSwiftAutoRetry.framework

Swift Package Manager

Swift Package Manager is is a tool for managing the distribution of Swift code and integrating it into compiler.

It only works with macOS.

Add dependency to your Package.swift file:

dependencies: [
.package(url: "https://github.com/SwingDev/RxSwiftAutoRetry.git", from: "0.9"))
]

Then, run below command:

pod install

Usage

See sample project in Example folder.

retryExponentially is extension method for RxSwift framework (in case to use this method please import RxSwift library.)

Usually using this method looks like it:

observable.retryExponentially()

This method provides set of default values for parameters so its behavior can be customized:

observable.retryExponentially(2, with: 0.9...1.1, scheduler: scheduler) { error in
//Add code
}
Parameters
  • maxAttemptCount - Maximum number of times to repeat the sequence.
  • jitter - Multiplier which randomize delay time. Randomizing value is chosen from given range.
  • scheduler - Scheduler on which the delay will be conducted
  • onRetry - Action which will be invoked after delay on every retry. This is optional parameter.
Default values
  • maxAttemptCount: 3
  • jitter: 0.9...1.1
  • scheduler: ConcurrentDispatchQueueScheduler(queue: DispatchQueue.global())
  • onRetry: nil

License

RxSwiftAutoRetry is available under the MIT license. See the LICENSE file for more info.

Description

  • Swift Tools 4.2.0
View More Packages from this Author

Dependencies

Last updated: Fri Oct 18 2024 04:41:01 GMT-0900 (Hawaii-Aleutian Daylight Time)