Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
crane-hiromu authored Oct 29, 2022
1 parent 46e8da5 commit b6dbf59
Showing 1 changed file with 66 additions and 1 deletion.
67 changes: 66 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int>(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<Int>(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

Expand Down

0 comments on commit b6dbf59

Please sign in to comment.