Skip to content

Instantly share code, notes, and snippets.

Last active Jan 5, 2023
What would you like to do?
extension Publisher where Self.Failure == Never {
func sink(receiveValue: @escaping ((Self.Output) async -> Void)) -> AnyCancellable {
sink { value in
Task {
await receiveValue(value)
// Allows writing sink without Task
.compactMap({ $0 })
.sink { [weak self] url in
await self?.processImageURL(url)
.store(in: &cancellables)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment