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.
Just<Int>(10)
.asyncMap { number in
await doSomething(number)
}
.sink { value in
// handle value
}
.store(in: &cancellable)
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(())
Just<Int>(10)
.asyncSink { number in
await doSomething(number)
}
.store(in: &cancellable)
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(())
Add the following dependency to your Package.swift file:
.package(url: "https://github.com/crane-hiromu/CombineAsyncable", "0.3.1"..<"1.0.0")
MIT, of course ;-) See the LICENSE file.