diff --git a/README.md b/README.md index 30b7d74..9074e95 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,72 @@ ## Description -wip +It bridges from Combine to Concurrency. + +A small set of extensions that allow to combine new swift concurrency with Combine. + +## Operator + +### .asyncMap + +```.swift +Just(10) + .asyncMap { number in + await doSomething(number) + } + .sink { value in + // handle value + } + .store(in: &cancellable) +``` + + +### .asyncMapWithThrows + +```.swift +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 + +```.swift +Just(10) + .sink { number in + await doSomething(number) + } + .store(in: &cancellable) +``` + +### .asyncSinkWithThrows + +```.swift +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