Swiftpack.co - crane-hiromu/CombineAsyncable as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by crane-hiromu.
crane-hiromu/CombineAsyncable 0.3.2
Bridge from Combine to Concurrency
⭐️ 26
🕓 5 weeks ago
.package(url: "https://github.com/crane-hiromu/CombineAsyncable.git", from: "0.3.2")

CombineAsyncable

Description

It bridges from Combine to Concurrency.

A small set of extensions that allow to combine new swift concurrency with Combine.

Here are the details in Japanese.

Operator

.asyncMap

Just<Int>(10)
    .asyncMap { number in
        await doSomething(number)
    }
    .sink { value in
        // handle value
    }
    .store(in: &cancellable)

.asyncMapWithThrows

let subject = PassthroughSubject<(), Never>()

subject
    .asyncMapWithThrows {
        try await APIClient.fetch()
    }
    .sink(receiveCompletion: { result in
        // handle result
    }, receiveValue: { value in
        // handle value
    })
    .store(in: &cancellable)

subject.send(())

.asyncSink

Just<Int>(10)
    .asyncSink { number in
        await doSomething(number)
    }
    .store(in: &cancellable)

.asyncSinkWithThrows

let subject = PassthroughSubject<(), Never>()

subject
    .setFailureType(to: Error.self)
    .asyncSinkWithThrows(receiveCompletion: { result in
        // handling result
    }, receiveValue: {
        let response = try await APIClient.fetch()
        // handling response
    })
    .store(in: &cancellable)

subject.send(())

Swift Package Manager

Add the following dependency to your Package.swift file:

.package(url: "https://github.com/crane-hiromu/CombineAsyncable", "0.3.1"..<"1.0.0")

License

MIT, of course ;-) See the LICENSE file.

GitHub

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

Release Notes

0.3.2
5 weeks ago

Thanks @Ryu0118 :)

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