Swiftpack.co - byoth/RxAsyncAwait as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by byoth.
byoth/RxAsyncAwait 0.1.1
RxSwift extensions for using asynchronous functions on streams.
⭐️ 0
🕓 3 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/byoth/RxAsyncAwait.git", from: "0.1.1")

RxAsyncAwait

SwiftPM Version Version Hits

RxAsyncAwait is an extension for using asynchronous functions on streams in RxSwift.

I don't think it's preferred, but if you need to use asynchronous functions in the RxSwift streams, you'll have to write some annoying code to handle it because RxSwift operators don't support easy use for asynchronous functions.

This library can keep your code simple even if that happens.

Usage

TryAwait

Observable.just("https://github.com/byoth")
    .compactMap { URL(string: $0) }
    .tryAwait { try await URLSession.shared.data(from: $0) }
    .subscribe()
    .disposed(by: disposeBag)

Await

Observable.just("https://github.com/byoth")
    .compactMap { URL(string: $0) }
    .await { await getData(from: $0) }
    .subscribe()
    .disposed(by: disposeBag)

func getData(from url: URL) async -> (Data, URLResponse)? {
    try? await URLSession.shared.data(from: url)
}

Installation

Swift Package Manager

import PackageDescription

let package = Package(
    name: "Your App",
    dependencies: [
        .package(url: "https://github.com/byoth/RxAsyncAwait.git", .upToNextMajor(from: "0.1.0")),
    ]
)

CocoaPods

target 'Your Target' do
    pod 'RxAsyncAwait', '~> 0.1'
end

Requirements

  • Xcode 13.2
  • Swift 5.5

Dependencies

GitHub

link
Stars: 0
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics