Created
January 1, 2021 22:51
-
-
Save jasdev/01a7497d7a5aa5d747c7abcb76f63773 to your computer and use it in GitHub Desktop.
Prefix while inclusive, passing values scaffolding.
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 { | |
func prefixInclusive(while predicate: @escaping (Output) -> Bool) -> AnyPublisher<Output, Failure> { | |
flatMap { value -> AnyPublisher<Output, Failure> in | |
if predicate(value) { | |
return Just(value) | |
.setFailureType(to: Failure.self) | |
.eraseToAnyPublisher() | |
} else { | |
fatalError("To be implemented.") | |
} | |
} | |
/* … */ | |
.eraseToAnyPublisher() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment