Created
January 23, 2021 03:54
-
-
Save jasdev/d6458b7ca8444beeaf036af56a8a2c0b to your computer and use it in GitHub Desktop.
Buffered subscribing, batched outputting in Combine.
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 Sequence where Element: Publisher { | |
func bufferedSubscribe(by size: Int) -> AnyPublisher<[Element.Output], Element.Failure> { | |
publisher | |
.flatMap(maxPublishers: .max(size)) { $0 } | |
.collect(size) | |
.eraseToAnyPublisher() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment