This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
$imageURL | |
.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