Giter Club home page Giter Club logo

hoc081098 / phdownloader Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 2.0 94 KB

Petrus Hoc's Downloader - Simple, reactive and functional downloader for iOS Swift with the power of RxSwift, RxAlamofire - RxSwift Downloader - RxDownloader

Home Page: https://cocoapods.org/pods/PhDownloader

License: MIT License

Swift 91.40% Objective-C 1.07% Ruby 7.52%
rxswift swift-downloader rxdownload swifty-downloader functional-reactive-programming rxalamofire ios swift swift5 ios-rx-downloader

phdownloader's Introduction

PhDownloader (Petrus Hoc's Downloader)

Simple, reactive and functional downloader for iOS Swift with the power of RxSwift, RxAlamofire. RxSwift Downloader. RxDownloader.

iOS Build CI Version License Platform Hits

Example

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

Requirements

Installation

PhDownloader is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'PhDownloader'

Author

Petrus Nguyễn Thái Học, [email protected]

Usagement

Create downloader

let downloader: PhDownloader = PhDownloaderFactory.makeDownloader(
    with: .init(
        maxConcurrent: 2,
        throttleProgress: .milliseconds(500)
    )
)

Obseve download result (for showing snackbar, toast, alert, ...)

downloader
    .downloadResult$
    .subscribe(onNext: { result in
        switch result {
        case .success(let request):
          ...
        case .failure(let request, let error):
          ...
        case .cancelled(let request):
          ...
        }
    })
    .disposed(by: disposeBag)

Obseve download state (for updating UI)

downloader
    .observe(by: ["id1", "id2", "id3"])
    .subscribe(onNext: { tasks in
        ...
    })
    .disposed(by: disposeBag)

downloader
    .observe(by: "Request id")
    .subscribe(onNext: { task in 
        ...
    })
    .disposed(by: disposeBag)

Enqueue, cancel, cancelAll, remove:

let id = "Request id"

downloader
    .enqueue(
        .init(
            identifier: id,
            url: URL(string: "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_1920_18MG.mp4")!,
            fileName: "test_file_\(id).mp4",
            savedDir: FileManager.default
                .urls(for: .documentDirectory, in: .userDomainMask)
                .first!
                .appendingPathComponent("downloads", isDirectory: true)
        )
    )
    .subscribe()
    .disposed(by: disposeBag)

downloader
    .cancel(by: id)
    .subscribe()
    .disposed(by: disposeBag)

downloader
    .cancelAll()
    .subscribe()
    .disposed(by: disposeBag)
    
downloader
    .remove(identifier: id)
    .subscribe()
    .disposed(by: disposeBag)

License

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

phdownloader's People

Contributors

hoc081098 avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

phdownloader's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

cocoapods
PhDownloader Example/Podfile
Podfile
  • Alamofire ~> 5.6
  • RxAlamofire ~> 6.1
  • RxSwift ~> 6.5
  • RxRelay ~> 6.5
  • RealmSwift ~> 10.40.1
  • RxRealm v5.0.6
github-actions
.github/workflows/ios-build.yml
  • actions/checkout v4@3df4ab11eba7bda6032a0b82a6bb43b11571feac
  • maxim-lobanov/setup-xcode v1.6.0
  • actions/cache v4
  • sersoft-gmbh/xcodebuild-action v3.0.0
  • macos 13
.github/workflows/ios-example-build.yml
  • actions/checkout v4@3df4ab11eba7bda6032a0b82a6bb43b11571feac
  • maxim-lobanov/setup-xcode v1.6.0
  • actions/cache v4
  • sersoft-gmbh/xcodebuild-action v3.0.0
  • macos 13
.github/workflows/publish-release.yml
  • actions/checkout v4@3df4ab11eba7bda6032a0b82a6bb43b11571feac

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.